diff options
| author | bors <bors@rust-lang.org> | 2014-05-30 21:21:39 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-05-30 21:21:39 -0700 |
| commit | 60a43f9bc5d24b47aae9681fc7ef47d517329e59 (patch) | |
| tree | c0e46f35c6d6482996e6b10eaf635201b51e82d4 /src/doc | |
| parent | cc4513202d6f9c6896054ebaa1d99230b06e9f10 (diff) | |
| parent | bb96ee6123082908dba86cb22344f0c23915bf06 (diff) | |
| download | rust-60a43f9bc5d24b47aae9681fc7ef47d517329e59.tar.gz rust-60a43f9bc5d24b47aae9681fc7ef47d517329e59.zip | |
auto merge of #14534 : alexcrichton/rust/snapshots, r=sfackler
This is part 2 of the saga of renaming the Partial/Total equality and comparison traits.
Diffstat (limited to 'src/doc')
| -rw-r--r-- | src/doc/rust.md | 26 | ||||
| -rw-r--r-- | src/doc/tutorial.md | 30 |
2 files changed, 28 insertions, 28 deletions
diff --git a/src/doc/rust.md b/src/doc/rust.md index bf4fd3dcc93..ee37cd2126c 100644 --- a/src/doc/rust.md +++ b/src/doc/rust.md @@ -1436,7 +1436,7 @@ trait Circle : Shape { fn radius() -> f64; } ~~~~ the syntax `Circle : Shape` means that types that implement `Circle` must also have an implementation for `Shape`. -Multiple supertraits are separated by `+`, `trait Circle : Shape + Eq { }`. +Multiple supertraits are separated by `+`, `trait Circle : Shape + PartialEq { }`. In an implementation of `Circle` for a given type `T`, methods can refer to `Shape` methods, since the typechecker checks that any type with an implementation of `Circle` also has an implementation of `Shape`. @@ -2159,23 +2159,23 @@ There are three different types of inline attributes: The `deriving` attribute allows certain traits to be automatically implemented for data structures. For example, the following will -create an `impl` for the `Eq` and `Clone` traits for `Foo`, the type -parameter `T` will be given the `Eq` or `Clone` constraints for the +create an `impl` for the `PartialEq` and `Clone` traits for `Foo`, the type +parameter `T` will be given the `PartialEq` or `Clone` constraints for the appropriate `impl`: ~~~~ -#[deriving(Eq, Clone)] +#[deriving(PartialEq, Clone)] struct Foo<T> { a: int, b: T } ~~~~ -The generated `impl` for `Eq` is equivalent to +The generated `impl` for `PartialEq` is equivalent to ~~~~ # struct Foo<T> { a: int, b: T } -impl<T: Eq> Eq for Foo<T> { +impl<T: PartialEq> PartialEq for Foo<T> { fn eq(&self, other: &Foo<T>) -> bool { self.a == other.a && self.b == other.b } @@ -2188,7 +2188,7 @@ impl<T: Eq> Eq for Foo<T> { Supported traits for `deriving` are: -* Comparison traits: `Eq`, `TotalEq`, `Ord`, `TotalOrd`. +* Comparison traits: `PartialEq`, `TotalEq`, `PartialOrd`, `TotalOrd`. * Serialization: `Encodable`, `Decodable`. These require `serialize`. * `Clone`, to create `T` from `&T` via a copy. * `Hash`, to iterate over the bytes in a data type. @@ -2734,22 +2734,22 @@ The default meaning of the operators on standard types is given here. * `==` : Equal to. - Calls the `eq` method on the `std::cmp::Eq` trait. + Calls the `eq` method on the `std::cmp::PartialEq` trait. * `!=` : Unequal to. - Calls the `ne` method on the `std::cmp::Eq` trait. + Calls the `ne` method on the `std::cmp::PartialEq` trait. * `<` : Less than. - Calls the `lt` method on the `std::cmp::Ord` trait. + Calls the `lt` method on the `std::cmp::PartialOrd` trait. * `>` : Greater than. - Calls the `gt` method on the `std::cmp::Ord` trait. + Calls the `gt` method on the `std::cmp::PartialOrd` trait. * `<=` : Less than or equal. - Calls the `le` method on the `std::cmp::Ord` trait. + Calls the `le` method on the `std::cmp::PartialOrd` trait. * `>=` : Greater than or equal. - Calls the `ge` method on the `std::cmp::Ord` trait. + Calls the `ge` method on the `std::cmp::PartialOrd` trait. #### Type cast expressions diff --git a/src/doc/tutorial.md b/src/doc/tutorial.md index a22256650b8..a4c89436d50 100644 --- a/src/doc/tutorial.md +++ b/src/doc/tutorial.md @@ -61,7 +61,7 @@ There are two ways to install the Rust compiler: by building from source or by downloading prebuilt binaries or installers for your platform. The [install page][rust-install] contains links to download binaries for both the nightly build and the most current Rust major release. For Windows and -OS X, the install page provides links to native installers. +OS X, the install page provides links to native installers. > *Note:* Windows users should read the detailed > [Getting started][wiki-start] notes on the wiki. Even when using @@ -69,8 +69,8 @@ OS X, the install page provides links to native installers. > the precise details of which are not discussed here. For Linux and OS X, the install page provides links to binary tarballs. -To install the Rust compiler from the from a binary tarball, download -the binary package, extract it, and execute the `install.sh` script in +To install the Rust compiler from the from a binary tarball, download +the binary package, extract it, and execute the `install.sh` script in the root directory of the package. To build the Rust compiler from source, you will need to obtain the source through @@ -1303,7 +1303,7 @@ be specified up-front. Our previous definition of list equality relied on the el the `==` operator available, and took advantage of the lack of a destructor on `u32` to copy it without a move of ownership. -We can add a *trait bound* on the `Eq` trait to require that the type implement the `==` operator. +We can add a *trait bound* on the `PartialEq` trait to require that the type implement the `==` operator. Two more `ref` annotations need to be added to avoid attempting to move out the element types: ~~~ @@ -1311,7 +1311,7 @@ Two more `ref` annotations need to be added to avoid attempting to move out the # Cons(T, Box<List<T>>), # Nil # } -fn eq<T: Eq>(xs: &List<T>, ys: &List<T>) -> bool { +fn eq<T: PartialEq>(xs: &List<T>, ys: &List<T>) -> bool { // Match on the next node in both lists. match (xs, ys) { // If we have reached the end of both lists, they are equal. @@ -1329,8 +1329,8 @@ let ys = Cons('c', box Cons('a', box Cons('t', box Nil))); assert!(eq(&xs, &ys)); ~~~ -This would be a good opportunity to implement the `Eq` trait for our list type, making the `==` and -`!=` operators available. We'll need to provide an `impl` for the `Eq` trait and a definition of the +This would be a good opportunity to implement the `PartialEq` trait for our list type, making the `==` and +`!=` operators available. We'll need to provide an `impl` for the `PartialEq` trait and a definition of the `eq` method. In a method, the `self` parameter refers to an instance of the type we're implementing on. @@ -1339,7 +1339,7 @@ on. # Cons(T, Box<List<T>>), # Nil # } -impl<T: Eq> Eq for List<T> { +impl<T: PartialEq> PartialEq for List<T> { fn eq(&self, ys: &List<T>) -> bool { // Match on the next node in both lists. match (self, ys) { @@ -1356,12 +1356,12 @@ impl<T: Eq> Eq for List<T> { let xs = Cons(5, box Cons(10, box Nil)); let ys = Cons(5, box Cons(10, box Nil)); -// The methods below are part of the Eq trait, +// The methods below are part of the PartialEq trait, // which we implemented on our linked list. assert!(xs.eq(&ys)); assert!(!xs.ne(&ys)); -// The Eq trait also allows us to use the shorthand infix operators. +// The PartialEq trait also allows us to use the shorthand infix operators. assert!(xs == ys); // `xs == ys` is short for `xs.eq(&ys)` assert!(!(xs != ys)); // `xs != ys` is short for `xs.ne(&ys)` ~~~ @@ -2345,12 +2345,12 @@ trait describes types that support an equality operation: ~~~~ // In a trait, `self` refers to the self argument. // `Self` refers to the type implementing the trait. -trait Eq { +trait PartialEq { fn equals(&self, other: &Self) -> bool; } // In an impl, `self` refers just to the value of the receiver -impl Eq for int { +impl PartialEq for int { fn equals(&self, other: &int) -> bool { *other == *self } } ~~~~ @@ -2600,13 +2600,13 @@ A small number of traits in `std` and `extra` can have implementations that can be automatically derived. These instances are specified by placing the `deriving` attribute on a data type declaration. For example, the following will mean that `Circle` has an implementation -for `Eq` and can be used with the equality operators, and that a value +for `PartialEq` and can be used with the equality operators, and that a value of type `ABC` can be randomly generated and converted to a string: ~~~ extern crate rand; -#[deriving(Eq)] +#[deriving(PartialEq)] struct Circle { radius: f64 } #[deriving(Rand, Show)] @@ -2618,7 +2618,7 @@ fn main() { } ~~~ -The full list of derivable traits is `Eq`, `TotalEq`, `Ord`, +The full list of derivable traits is `PartialEq`, `TotalEq`, `Ord`, `TotalOrd`, `Encodable`, `Decodable`, `Clone`, `Hash`, `Rand`, `Default`, `Zero`, `FromPrimitive` and `Show`. |
