-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Chapter 11.1 Listing 11-7 displayed code is incorrect #1206
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
Comments
The main() should be removed in the expanded code, it is unnecessary |
This fix should be applied to all further examples in Chapter 11.1 as all code is executed using cargo test in the src/lib.rs and does not require a main() |
Yup, you're right. Adding a hidden We'd love a pull request! ❤️ |
Ahh, I see. Took a look at the example in the link, thanks. making a pull request |
I submitted the pull request, I also did one for chapter 13.3 example 13-27 with the same issue. Thanks for letting me help. |
Uh oh!
There was an error while loading. Please reload this page.
Example 11-7 is supposed to be a passing example but the listed code results in a failure to compile
Code listed is as follows:
#![allow(unused_variables)]
fn main() {
pub fn add_two(a: i32) -> i32 {
a + 2
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_adds_two() {
assert_eq!(4, add_two(2));
}
}
}
//Should result in:
running 1 test
test tests::it_adds_two ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
//Instead results in:
error[E0425]: cannot find function
greeting
in this scope--> src/lib.rs:14:22
|
14 | let result = greeting("Carol");
| ^^^^^^^^ not found in this scope
warning: unused import:
super::*
--> src/lib.rs:10:9
|
10 | use super::*;
| ^^^^^^^^
|
= note: #[warn(unused_imports)] on by default
warning: function is never used:
main
--> src/lib.rs:3:1
|
3 | fn main() {
| ^^^^^^^^^
|
= note: #[warn(dead_code)] on by default
error: aborting due to previous error
error: Could not compile
adder
.warning: build failed, waiting for other jobs to finish...
error: build failed
I can fix and submit if allowed. Thanks love the book
The text was updated successfully, but these errors were encountered: