Skip to content

PR to fix issue 7689 ("Documentation Hides Imports Too Aggressively") #7954

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions doc/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -499,8 +499,8 @@ types.
> items.

~~~~
# use std::float;
# use std::num::atan;
use std::float;
use std::num::atan;
fn angle(vector: (float, float)) -> float {
let pi = float::consts::pi;
match vector {
Expand Down Expand Up @@ -555,7 +555,7 @@ while cake_amount > 0 {
`loop` denotes an infinite loop, and is the preferred way of writing `while true`:

~~~~
# use std::int;
use std::int;
let mut x = 5;
loop {
x += x - 3;
Expand Down Expand Up @@ -701,7 +701,7 @@ get at their contents. All variant constructors can be used as
patterns, as in this definition of `area`:

~~~~
# use std::float;
use std::float;
# struct Point {x: float, y: float}
# enum Shape { Circle(Point, float), Rectangle(Point, Point) }
fn area(sh: Shape) -> float {
Expand Down Expand Up @@ -733,7 +733,7 @@ fn point_from_direction(dir: Direction) -> Point {
Enum variants may also be structs. For example:

~~~~
# use std::float;
use std::float;
# struct Point { x: float, y: float }
# fn square(x: float) -> float { x * x }
enum Shape {
Expand Down Expand Up @@ -1599,7 +1599,8 @@ lists back to back. Since that is so unsightly, empty argument lists
may be omitted from `do` expressions.

~~~~
# use std::task::spawn;
use std::task::spawn;

do spawn {
debug!("Kablam!");
}
Expand Down Expand Up @@ -1728,7 +1729,7 @@ impl Circle {
To call such a method, just prefix it with the type name and a double colon:

~~~~
# use std::float::consts::pi;
use std::float::consts::pi;
struct Circle { radius: float }
impl Circle {
fn new(area: float) -> Circle { Circle { radius: (area / pi).sqrt() } }
Expand Down Expand Up @@ -1774,7 +1775,7 @@ illegal to copy and pass by value.
Generic `type`, `struct`, and `enum` declarations follow the same pattern:

~~~~
# use std::hashmap::HashMap;
use std::hashmap::HashMap;
type Set<T> = HashMap<T, ()>;

struct Stack<T> {
Expand Down Expand Up @@ -2000,7 +2001,7 @@ name and a double colon. The compiler uses type inference to decide which
implementation to use.

~~~~
# use std::float::consts::pi;
use std::float::consts::pi;
trait Shape { fn new(area: float) -> Self; }
struct Circle { radius: float }
struct Square { length: float }
Expand Down Expand Up @@ -2156,7 +2157,7 @@ trait Circle : Shape { fn radius(&self) -> float; }
Now, we can implement `Circle` on a type only if we also implement `Shape`.

~~~~
# use std::float::consts::pi;
use std::float::consts::pi;
# trait Shape { fn area(&self) -> float; }
# trait Circle : Shape { fn radius(&self) -> float; }
# struct Point { x: float, y: float }
Expand Down Expand Up @@ -2191,7 +2192,7 @@ fn radius_times_area<T: Circle>(c: T) -> float {
Likewise, supertrait methods may also be called on trait objects.

~~~ {.xfail-test}
# use std::float::consts::pi;
use std::float::consts::pi;
# trait Shape { fn area(&self) -> float; }
# trait Circle : Shape { fn radius(&self) -> float; }
# struct Point { x: float, y: float }
Expand Down