Skip to content

Commit

Permalink
Exposed previously hidden 'use' statements in the tutorial's sample c…
Browse files Browse the repository at this point in the history
…ode.
  • Loading branch information
zslayton committed Jul 22, 2013
1 parent e336cbf commit 49014c8
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions doc/tutorial.md
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

9 comments on commit 49014c8

@bors
Copy link
Contributor

@bors bors commented on 49014c8 Jul 23, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from huonw
at zslayton@49014c8

@bors
Copy link
Contributor

@bors bors commented on 49014c8 Jul 23, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging zslayton/rust/master = 49014c8 into auto

@bors
Copy link
Contributor

@bors bors commented on 49014c8 Jul 23, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zslayton/rust/master = 49014c8 merged ok, testing candidate = efa2736c

@bors
Copy link
Contributor

@bors bors commented on 49014c8 Jul 23, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from huonw
at zslayton@49014c8

@bors
Copy link
Contributor

@bors bors commented on 49014c8 Jul 23, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging zslayton/rust/master = 49014c8 into auto

@bors
Copy link
Contributor

@bors bors commented on 49014c8 Jul 23, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zslayton/rust/master = 49014c8 merged ok, testing candidate = e029c2d

@bors
Copy link
Contributor

@bors bors commented on 49014c8 Jul 23, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = e029c2d

Please sign in to comment.