Skip to content

Commit 20a2fbd

Browse files
committed
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
1 parent 2ed1cfc commit 20a2fbd

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

doc/rust.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -802,11 +802,11 @@ Use declarations support a number of convenient shortcuts:
802802
An example of `use` declarations:
803803

804804
~~~~
805-
use std::float::sin;
805+
use std::num::sin;
806806
use std::option::{Some, None};
807807
808808
fn main() {
809-
// Equivalent to 'info!(std::float::sin(1.0));'
809+
// Equivalent to 'info!(std::num::sin(1.0));'
810810
info!(sin(1.0));
811811
812812
// Equivalent to 'info!(~[std::option::Some(1.0), std::option::None]);'

doc/tutorial.md

+7-10
Original file line numberDiff line numberDiff line change
@@ -503,12 +503,13 @@ types.
503503
504504
~~~~
505505
# use std::float;
506+
# use std::num::atan;
506507
fn angle(vector: (float, float)) -> float {
507508
let pi = float::consts::pi;
508509
match vector {
509510
(0f, y) if y < 0f => 1.5 * pi,
510511
(0f, y) => 0.5 * pi,
511-
(x, y) => float::atan(y / x)
512+
(x, y) => atan(y / x)
512513
}
513514
}
514515
~~~~
@@ -1728,10 +1729,9 @@ To call such a method, just prefix it with the type name and a double colon:
17281729

17291730
~~~~
17301731
# use std::float::consts::pi;
1731-
# use std::float::sqrt;
17321732
struct Circle { radius: float }
17331733
impl Circle {
1734-
fn new(area: float) -> Circle { Circle { radius: sqrt(area / pi) } }
1734+
fn new(area: float) -> Circle { Circle { radius: (area / pi).sqrt() } }
17351735
}
17361736
let c = Circle::new(42.5);
17371737
~~~~
@@ -1997,16 +1997,15 @@ implementation to use.
19971997

19981998
~~~~
19991999
# use std::float::consts::pi;
2000-
# use std::float::sqrt;
20012000
trait Shape { fn new(area: float) -> Self; }
20022001
struct Circle { radius: float }
20032002
struct Square { length: float }
20042003
20052004
impl Shape for Circle {
2006-
fn new(area: float) -> Circle { Circle { radius: sqrt(area / pi) } }
2005+
fn new(area: float) -> Circle { Circle { radius: (area / pi).sqrt() } }
20072006
}
20082007
impl Shape for Square {
2009-
fn new(area: float) -> Square { Square { length: sqrt(area) } }
2008+
fn new(area: float) -> Square { Square { length: (area).sqrt() } }
20102009
}
20112010
20122011
let area = 42.5;
@@ -2154,14 +2153,13 @@ Now, we can implement `Circle` on a type only if we also implement `Shape`.
21542153

21552154
~~~~
21562155
# use std::float::consts::pi;
2157-
# use std::float::sqrt;
21582156
# trait Shape { fn area(&self) -> float; }
21592157
# trait Circle : Shape { fn radius(&self) -> float; }
21602158
# struct Point { x: float, y: float }
21612159
# fn square(x: float) -> float { x * x }
21622160
struct CircleStruct { center: Point, radius: float }
21632161
impl Circle for CircleStruct {
2164-
fn radius(&self) -> float { sqrt(self.area() / pi) }
2162+
fn radius(&self) -> float { (self.area() / pi).sqrt() }
21652163
}
21662164
impl Shape for CircleStruct {
21672165
fn area(&self) -> float { pi * square(self.radius) }
@@ -2190,12 +2188,11 @@ Likewise, supertrait methods may also be called on trait objects.
21902188

21912189
~~~ {.xfail-test}
21922190
# use std::float::consts::pi;
2193-
# use std::float::sqrt;
21942191
# trait Shape { fn area(&self) -> float; }
21952192
# trait Circle : Shape { fn radius(&self) -> float; }
21962193
# struct Point { x: float, y: float }
21972194
# struct CircleStruct { center: Point, radius: float }
2198-
# impl Circle for CircleStruct { fn radius(&self) -> float { sqrt(self.area() / pi) } }
2195+
# impl Circle for CircleStruct { fn radius(&self) -> float { (self.area() / pi).sqrt() } }
21992196
# impl Shape for CircleStruct { fn area(&self) -> float { pi * square(self.radius) } }
22002197
22012198
let concrete = @CircleStruct{center:Point{x:3f,y:4f},radius:5f};

0 commit comments

Comments
 (0)