Closed
Description
Another ticket, issue #1127 describes how dropping the std import will give confusing error messages when compiling with --test. In addition to improving those error messages, the tutorial should be very clear about this need.
The example already includes std:
use std;
fn twice(x: int) -> int { x + x }
#[test]
fn test_twice() {
let mut i = -100;
while i < 100 {
assert twice(i) == 2 * i;
i += 1;
}
}
However the surrounding text does not emphasize that "use std" is necessary for tests. A complementary fix (and quicker) to #1127 is to simple change the sentence preceding the code snippet to something like this:
"Tests can be interspersed with other code, and annotated with the #[test] attribute. The #[test] attribute requires std to be in scope, so "use std" is required for compiling test code."