Skip to content

Commit

Permalink
I forgot the changes to the docs as well
Browse files Browse the repository at this point in the history
Apparently yesterday wasn't my day, and I forgot to add the changes to
all the tests apparently, and in the end forgot the docs extra much.
Please documentation, forgive me, I really do love you, I hope you
forgive me.

Next time we'll meet tutorial, I promise to bring cookies and tea. I
really want to be best-friends-forever with you, <3.

XOXO
  • Loading branch information
auroranockert committed Jul 9, 2013
1 parent 2ed1cfc commit 20a2fbd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
4 changes: 2 additions & 2 deletions doc/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -802,11 +802,11 @@ Use declarations support a number of convenient shortcuts:
An example of `use` declarations:

~~~~
use std::float::sin;
use std::num::sin;
use std::option::{Some, None};
fn main() {
// Equivalent to 'info!(std::float::sin(1.0));'
// Equivalent to 'info!(std::num::sin(1.0));'
info!(sin(1.0));
// Equivalent to 'info!(~[std::option::Some(1.0), std::option::None]);'
Expand Down
17 changes: 7 additions & 10 deletions doc/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -503,12 +503,13 @@ types.
~~~~
# use std::float;
# use std::num::atan;
fn angle(vector: (float, float)) -> float {
let pi = float::consts::pi;
match vector {
(0f, y) if y < 0f => 1.5 * pi,
(0f, y) => 0.5 * pi,
(x, y) => float::atan(y / x)
(x, y) => atan(y / x)
}
}
~~~~
Expand Down Expand Up @@ -1728,10 +1729,9 @@ To call such a method, just prefix it with the type name and a double colon:

~~~~
# use std::float::consts::pi;
# use std::float::sqrt;
struct Circle { radius: float }
impl Circle {
fn new(area: float) -> Circle { Circle { radius: sqrt(area / pi) } }
fn new(area: float) -> Circle { Circle { radius: (area / pi).sqrt() } }
}
let c = Circle::new(42.5);
~~~~
Expand Down Expand Up @@ -1997,16 +1997,15 @@ implementation to use.

~~~~
# use std::float::consts::pi;
# use std::float::sqrt;
trait Shape { fn new(area: float) -> Self; }
struct Circle { radius: float }
struct Square { length: float }
impl Shape for Circle {
fn new(area: float) -> Circle { Circle { radius: sqrt(area / pi) } }
fn new(area: float) -> Circle { Circle { radius: (area / pi).sqrt() } }
}
impl Shape for Square {
fn new(area: float) -> Square { Square { length: sqrt(area) } }
fn new(area: float) -> Square { Square { length: (area).sqrt() } }
}
let area = 42.5;
Expand Down Expand Up @@ -2154,14 +2153,13 @@ Now, we can implement `Circle` on a type only if we also implement `Shape`.

~~~~
# use std::float::consts::pi;
# use std::float::sqrt;
# trait Shape { fn area(&self) -> float; }
# trait Circle : Shape { fn radius(&self) -> float; }
# struct Point { x: float, y: float }
# fn square(x: float) -> float { x * x }
struct CircleStruct { center: Point, radius: float }
impl Circle for CircleStruct {
fn radius(&self) -> float { sqrt(self.area() / pi) }
fn radius(&self) -> float { (self.area() / pi).sqrt() }
}
impl Shape for CircleStruct {
fn area(&self) -> float { pi * square(self.radius) }
Expand Down Expand Up @@ -2190,12 +2188,11 @@ Likewise, supertrait methods may also be called on trait objects.

~~~ {.xfail-test}
# use std::float::consts::pi;
# use std::float::sqrt;
# trait Shape { fn area(&self) -> float; }
# trait Circle : Shape { fn radius(&self) -> float; }
# struct Point { x: float, y: float }
# struct CircleStruct { center: Point, radius: float }
# impl Circle for CircleStruct { fn radius(&self) -> float { sqrt(self.area() / pi) } }
# impl Circle for CircleStruct { fn radius(&self) -> float { (self.area() / pi).sqrt() } }
# impl Shape for CircleStruct { fn area(&self) -> float { pi * square(self.radius) } }
let concrete = @CircleStruct{center:Point{x:3f,y:4f},radius:5f};
Expand Down

0 comments on commit 20a2fbd

Please sign in to comment.