diff options
| author | Jens Nockert <jens@nockert.se> | 2013-07-09 18:24:30 +0200 |
|---|---|---|
| committer | Jens Nockert <jens@nockert.se> | 2013-07-09 18:24:30 +0200 |
| commit | 20a2fbd05557b21b7e3f38d17250388a350d3484 (patch) | |
| tree | b47a56c7915f0495526bf3942e5d4b53df32d010 | |
| parent | 2ed1cfc91224810254ac54ab6245c5edcc73c647 (diff) | |
| download | rust-20a2fbd05557b21b7e3f38d17250388a350d3484.tar.gz rust-20a2fbd05557b21b7e3f38d17250388a350d3484.zip | |
I forgot the changes to the docs as well
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
| -rw-r--r-- | doc/rust.md | 4 | ||||
| -rw-r--r-- | doc/tutorial.md | 17 |
2 files changed, 9 insertions, 12 deletions
diff --git a/doc/rust.md b/doc/rust.md index 42a010b114a..0a640648222 100644 --- a/doc/rust.md +++ b/doc/rust.md @@ -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]);' diff --git a/doc/tutorial.md b/doc/tutorial.md index c8280a99182..b282679b1a1 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -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) } } ~~~~ @@ -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); ~~~~ @@ -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; @@ -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) } @@ -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}; |
