Skip to content

Commit d1e9d3e

Browse files
committed
---
yaml --- r: 145685 b: refs/heads/try2 c: 2076073 h: refs/heads/master i: 145683: b0efeb9 v: v3
1 parent ca4685a commit d1e9d3e

File tree

217 files changed

+1536
-2761
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

217 files changed

+1536
-2761
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 8f6e43e273eac4b9fc1202d09369af3d98957ebd
8+
refs/heads/try2: 20760739e9bbafc5a7abb0fe4249c5cf6d58ecef
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/doc/rust.md

Lines changed: 34 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -363,19 +363,17 @@ A _floating-point literal_ has one of two forms:
363363
second decimal literal.
364364
* A single _decimal literal_ followed by an _exponent_.
365365

366-
By default, a floating-point literal is of type `float`. A
367-
floating-point literal may be followed (immediately, without any
368-
spaces) by a _floating-point suffix_, which changes the type of the
369-
literal. There are three floating-point suffixes: `f` (for the base
370-
`float` type), `f32`, and `f64` (the 32-bit and 64-bit floating point
371-
types).
366+
By default, a floating-point literal has a generic type, but will fall back to
367+
`f64`. A floating-point literal may be followed (immediately, without any
368+
spaces) by a _floating-point suffix_, which changes the type of the literal.
369+
There are two floating-point suffixes: `f32`, and `f64` (the 32-bit and 64-bit
370+
floating point types).
372371

373372
Examples of floating-point literals of various forms:
374373

375374
~~~~
376-
123.0; // type float
377-
0.1; // type float
378-
3f; // type float
375+
123.0; // type f64
376+
0.1; // type f64
379377
0.1f32; // type f32
380378
12E+99_f64; // type f64
381379
~~~~
@@ -1179,8 +1177,8 @@ a = Cat;
11791177
Enumeration constructors can have either named or unnamed fields:
11801178
~~~~
11811179
enum Animal {
1182-
Dog (~str, float),
1183-
Cat { name: ~str, weight: float }
1180+
Dog (~str, f64),
1181+
Cat { name: ~str, weight: f64 }
11841182
}
11851183
11861184
let mut a: Animal = Dog(~"Cocoa", 37.2);
@@ -1344,17 +1342,17 @@ For example:
13441342
trait Num {
13451343
fn from_int(n: int) -> Self;
13461344
}
1347-
impl Num for float {
1348-
fn from_int(n: int) -> float { n as float }
1345+
impl Num for f64 {
1346+
fn from_int(n: int) -> f64 { n as f64 }
13491347
}
1350-
let x: float = Num::from_int(42);
1348+
let x: f64 = Num::from_int(42);
13511349
~~~~
13521350

13531351
Traits may inherit from other traits. For example, in
13541352

13551353
~~~~
1356-
trait Shape { fn area() -> float; }
1357-
trait Circle : Shape { fn radius() -> float; }
1354+
trait Shape { fn area() -> f64; }
1355+
trait Circle : Shape { fn radius() -> f64; }
13581356
~~~~
13591357

13601358
the syntax `Circle : Shape` means that types that implement `Circle` must also have an implementation for `Shape`.
@@ -1367,9 +1365,9 @@ methods of the supertrait may be called on values of subtrait-bound type paramet
13671365
Referring to the previous example of `trait Circle : Shape`:
13681366

13691367
~~~
1370-
# trait Shape { fn area(&self) -> float; }
1371-
# trait Circle : Shape { fn radius(&self) -> float; }
1372-
fn radius_times_area<T: Circle>(c: T) -> float {
1368+
# trait Shape { fn area(&self) -> f64; }
1369+
# trait Circle : Shape { fn radius(&self) -> f64; }
1370+
fn radius_times_area<T: Circle>(c: T) -> f64 {
13731371
// `c` is both a Circle and a Shape
13741372
c.radius() * c.area()
13751373
}
@@ -1378,10 +1376,10 @@ fn radius_times_area<T: Circle>(c: T) -> float {
13781376
Likewise, supertrait methods may also be called on trait objects.
13791377

13801378
~~~ {.xfail-test}
1381-
# trait Shape { fn area(&self) -> float; }
1382-
# trait Circle : Shape { fn radius(&self) -> float; }
1383-
# impl Shape for int { fn area(&self) -> float { 0.0 } }
1384-
# impl Circle for int { fn radius(&self) -> float { 0.0 } }
1379+
# trait Shape { fn area(&self) -> f64; }
1380+
# trait Circle : Shape { fn radius(&self) -> f64; }
1381+
# impl Shape for int { fn area(&self) -> f64 { 0.0 } }
1382+
# impl Circle for int { fn radius(&self) -> f64 { 0.0 } }
13851383
# let mycircle = 0;
13861384
13871385
let mycircle: Circle = @mycircle as @Circle;
@@ -1395,14 +1393,14 @@ An _implementation_ is an item that implements a [trait](#traits) for a specific
13951393
Implementations are defined with the keyword `impl`.
13961394

13971395
~~~~
1398-
# struct Point {x: float, y: float};
1396+
# struct Point {x: f64, y: f64};
13991397
# type Surface = int;
1400-
# struct BoundingBox {x: float, y: float, width: float, height: float};
1398+
# struct BoundingBox {x: f64, y: f64, width: f64, height: f64};
14011399
# trait Shape { fn draw(&self, Surface); fn bounding_box(&self) -> BoundingBox; }
14021400
# fn do_draw_circle(s: Surface, c: Circle) { }
14031401
14041402
struct Circle {
1405-
radius: float,
1403+
radius: f64,
14061404
center: Point,
14071405
}
14081406
@@ -1970,7 +1968,7 @@ values.
19701968

19711969
~~~~~~~~ {.tuple}
19721970
(0,);
1973-
(0f, 4.5f);
1971+
(0.0, 4.5);
19741972
("a", 4u, true);
19751973
~~~~~~~~
19761974

@@ -2002,12 +2000,12 @@ A _unit-like structure expression_ consists only of the [path](#paths) of a [str
20022000
The following are examples of structure expressions:
20032001

20042002
~~~~
2005-
# struct Point { x: float, y: float }
2006-
# struct TuplePoint(float, float);
2003+
# struct Point { x: f64, y: f64 }
2004+
# struct TuplePoint(f64, f64);
20072005
# mod game { pub struct User<'self> { name: &'self str, age: uint, score: uint } }
20082006
# struct Cookie; fn some_fn<T>(t: T) {}
2009-
Point {x: 10f, y: 20f};
2010-
TuplePoint(10f, 20f);
2007+
Point {x: 10.0, y: 20.0};
2008+
TuplePoint(10.0, 20.0);
20112009
let u = game::User {name: "Joe", age: 35, score: 100_000};
20122010
some_fn::<Cookie>(Cookie);
20132011
~~~~
@@ -2248,12 +2246,12 @@ Any other cast is unsupported and will fail to compile.
22482246
An example of an `as` expression:
22492247

22502248
~~~~
2251-
# fn sum(v: &[float]) -> float { 0.0 }
2252-
# fn len(v: &[float]) -> int { 0 }
2249+
# fn sum(v: &[f64]) -> f64 { 0.0 }
2250+
# fn len(v: &[f64]) -> int { 0 }
22532251
2254-
fn avg(v: &[float]) -> float {
2255-
let sum: float = sum(v);
2256-
let sz: float = len(v) as float;
2252+
fn avg(v: &[f64]) -> f64 {
2253+
let sum: f64 = sum(v);
2254+
let sz: f64 = len(v) as f64;
22572255
return sum / sz;
22582256
}
22592257
~~~~
@@ -2767,19 +2765,6 @@ size, in bits, is equal to the size of the rust type `uint` on the same target
27672765
machine.
27682766

27692767

2770-
#### Machine-dependent floating point type
2771-
2772-
The Rust type `float` is a machine-specific type equal to one of the supported
2773-
Rust floating-point machine types (`f32` or `f64`). It is the largest
2774-
floating-point type that is directly supported by hardware on the target
2775-
machine, or if the target machine has no floating-point hardware support, the
2776-
largest floating-point type supported by the software floating-point library
2777-
used to support the other floating-point machine types.
2778-
2779-
Note that due to the preference for hardware-supported floating-point, the
2780-
type `float` may not be equal to the largest *supported* floating-point type.
2781-
2782-
27832768
### Textual types
27842769

27852770
The types `char` and `str` hold textual data.

0 commit comments

Comments
 (0)