Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update listings 11-01 and 11-03 with add function generated by cargo #3630

Conversation

Jbonez87
Copy link

@Jbonez87 Jbonez87 commented May 1, 2023

This updates the testing code in chapter 11 to reflect what cargo will generate when running cargo new adder --lib.

@matthewjnield
Copy link
Contributor

To add to this, since the testing code generated by cargo automatically includes the line use super::*;, the following paragraph in Chapter 1.1 which describes this line being manually added to Listing 11-6 and the reason for doing so is misleading. Perhaps the paragraph should be moved to Listing 11-1, and altered so that is explaining why the line is (already) there.

Note that we’ve added a new line inside the tests module: use super::*;.
The tests module is a regular module that follows the usual visibility rules
we covered in Chapter 7 in the [“Paths for Referring to an Item in the Module
Tree”][paths-for-referring-to-an-item-in-the-module-tree]
section. Because the tests module is an inner module, we need to bring the
code under test in the outer module into the scope of the inner module. We use
a glob here so anything we define in the outer module is available to this
tests module.

@chriskrycho
Copy link
Contributor

This specific bit was fixed via #3533. I am going to turn your comment into an issue tracking that clarification, @matthewjnield – thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants