Skip to content

Commit 7e90bc6

Browse files
committed
---
yaml --- r: 95137 b: refs/heads/dist-snap c: c463772 h: refs/heads/master i: 95135: 9e567f9 v: v3
1 parent 4abbaf9 commit 7e90bc6

File tree

207 files changed

+2751
-1445
lines changed

Some content is hidden

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

207 files changed

+2751
-1445
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: c274a6888410ce3e357e014568b43310ed787d36
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: c44826fdcd036982b955407677c5ec4ce1f834ce
9+
refs/heads/dist-snap: c463772ebdbfca65017ac1bc2c8322d229b291a9
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/doc/rust.md

Lines changed: 49 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -363,17 +363,19 @@ 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 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).
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).
371372

372373
Examples of floating-point literals of various forms:
373374

374375
~~~~
375-
123.0; // type f64
376-
0.1; // type f64
376+
123.0; // type float
377+
0.1; // type float
378+
3f; // type float
377379
0.1f32; // type f32
378380
12E+99_f64; // type f64
379381
~~~~
@@ -1177,8 +1179,8 @@ a = Cat;
11771179
Enumeration constructors can have either named or unnamed fields:
11781180
~~~~
11791181
enum Animal {
1180-
Dog (~str, f64),
1181-
Cat { name: ~str, weight: f64 }
1182+
Dog (~str, float),
1183+
Cat { name: ~str, weight: float }
11821184
}
11831185
11841186
let mut a: Animal = Dog(~"Cocoa", 37.2);
@@ -1342,17 +1344,17 @@ For example:
13421344
trait Num {
13431345
fn from_int(n: int) -> Self;
13441346
}
1345-
impl Num for f64 {
1346-
fn from_int(n: int) -> f64 { n as f64 }
1347+
impl Num for float {
1348+
fn from_int(n: int) -> float { n as float }
13471349
}
1348-
let x: f64 = Num::from_int(42);
1350+
let x: float = Num::from_int(42);
13491351
~~~~
13501352

13511353
Traits may inherit from other traits. For example, in
13521354

13531355
~~~~
1354-
trait Shape { fn area() -> f64; }
1355-
trait Circle : Shape { fn radius() -> f64; }
1356+
trait Shape { fn area() -> float; }
1357+
trait Circle : Shape { fn radius() -> float; }
13561358
~~~~
13571359

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

13671369
~~~
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 {
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 {
13711373
// `c` is both a Circle and a Shape
13721374
c.radius() * c.area()
13731375
}
@@ -1376,10 +1378,10 @@ fn radius_times_area<T: Circle>(c: T) -> f64 {
13761378
Likewise, supertrait methods may also be called on trait objects.
13771379

13781380
~~~ {.xfail-test}
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 } }
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 } }
13831385
# let mycircle = 0;
13841386
13851387
let mycircle: Circle = @mycircle as @Circle;
@@ -1393,14 +1395,14 @@ An _implementation_ is an item that implements a [trait](#traits) for a specific
13931395
Implementations are defined with the keyword `impl`.
13941396

13951397
~~~~
1396-
# struct Point {x: f64, y: f64};
1398+
# struct Point {x: float, y: float};
13971399
# type Surface = int;
1398-
# struct BoundingBox {x: f64, y: f64, width: f64, height: f64};
1400+
# struct BoundingBox {x: float, y: float, width: float, height: float};
13991401
# trait Shape { fn draw(&self, Surface); fn bounding_box(&self) -> BoundingBox; }
14001402
# fn do_draw_circle(s: Surface, c: Circle) { }
14011403
14021404
struct Circle {
1403-
radius: f64,
1405+
radius: float,
14041406
center: Point,
14051407
}
14061408
@@ -1968,7 +1970,7 @@ values.
19681970

19691971
~~~~~~~~ {.tuple}
19701972
(0,);
1971-
(0.0, 4.5);
1973+
(0f, 4.5f);
19721974
("a", 4u, true);
19731975
~~~~~~~~
19741976

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

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

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

27672769

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+
27682783
### Textual types
27692784

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

0 commit comments

Comments
 (0)