@@ -61,16 +61,16 @@ There are two ways to install the Rust compiler: by building from source or
6161by downloading prebuilt binaries or installers for your platform. The
6262[ install page] [ rust-install ] contains links to download binaries for both
6363the nightly build and the most current Rust major release. For Windows and
64- OS X, the install page provides links to native installers.
64+ OS X, the install page provides links to native installers.
6565
6666> * Note:* Windows users should read the detailed
6767> [ Getting started] [ wiki-start ] notes on the wiki. Even when using
6868> the binary installer, the Windows build requires a MinGW installation,
6969> the precise details of which are not discussed here.
7070
7171For Linux and OS X, the install page provides links to binary tarballs.
72- To install the Rust compiler from the from a binary tarball, download
73- the binary package, extract it, and execute the ` install.sh ` script in
72+ To install the Rust compiler from the from a binary tarball, download
73+ the binary package, extract it, and execute the ` install.sh ` script in
7474the root directory of the package.
7575
7676To build the Rust compiler from source, you will need to obtain the source through
@@ -1303,15 +1303,15 @@ be specified up-front. Our previous definition of list equality relied on the el
13031303the ` == ` operator available, and took advantage of the lack of a destructor on ` u32 ` to copy it
13041304without a move of ownership.
13051305
1306- We can add a * trait bound* on the ` Eq ` trait to require that the type implement the ` == ` operator.
1306+ We can add a * trait bound* on the ` PartialEq ` trait to require that the type implement the ` == ` operator.
13071307Two more ` ref ` annotations need to be added to avoid attempting to move out the element types:
13081308
13091309~~~
13101310# enum List<T> {
13111311# Cons(T, Box<List<T>>),
13121312# Nil
13131313# }
1314- fn eq<T: Eq >(xs: &List<T>, ys: &List<T>) -> bool {
1314+ fn eq<T: PartialEq >(xs: &List<T>, ys: &List<T>) -> bool {
13151315 // Match on the next node in both lists.
13161316 match (xs, ys) {
13171317 // 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)));
13291329assert!(eq(&xs, &ys));
13301330~~~
13311331
1332- This would be a good opportunity to implement the ` Eq ` trait for our list type, making the ` == ` and
1333- ` != ` operators available. We'll need to provide an ` impl ` for the ` Eq ` trait and a definition of the
1332+ This would be a good opportunity to implement the ` PartialEq ` trait for our list type, making the ` == ` and
1333+ ` != ` operators available. We'll need to provide an ` impl ` for the ` PartialEq ` trait and a definition of the
13341334` eq ` method. In a method, the ` self ` parameter refers to an instance of the type we're implementing
13351335on.
13361336
@@ -1339,7 +1339,7 @@ on.
13391339# Cons(T, Box<List<T>>),
13401340# Nil
13411341# }
1342- impl<T: Eq> Eq for List<T> {
1342+ impl<T: PartialEq> PartialEq for List<T> {
13431343 fn eq(&self, ys: &List<T>) -> bool {
13441344 // Match on the next node in both lists.
13451345 match (self, ys) {
@@ -1356,12 +1356,12 @@ impl<T: Eq> Eq for List<T> {
13561356
13571357let xs = Cons(5, box Cons(10, box Nil));
13581358let ys = Cons(5, box Cons(10, box Nil));
1359- // The methods below are part of the Eq trait,
1359+ // The methods below are part of the PartialEq trait,
13601360// which we implemented on our linked list.
13611361assert!(xs.eq(&ys));
13621362assert!(!xs.ne(&ys));
13631363
1364- // The Eq trait also allows us to use the shorthand infix operators.
1364+ // The PartialEq trait also allows us to use the shorthand infix operators.
13651365assert!(xs == ys); // `xs == ys` is short for `xs.eq(&ys)`
13661366assert!(!(xs != ys)); // `xs != ys` is short for `xs.ne(&ys)`
13671367~~~
@@ -2345,12 +2345,12 @@ trait describes types that support an equality operation:
23452345~~~~
23462346// In a trait, `self` refers to the self argument.
23472347// `Self` refers to the type implementing the trait.
2348- trait Eq {
2348+ trait PartialEq {
23492349 fn equals(&self, other: &Self) -> bool;
23502350}
23512351
23522352// In an impl, `self` refers just to the value of the receiver
2353- impl Eq for int {
2353+ impl PartialEq for int {
23542354 fn equals(&self, other: &int) -> bool { *other == *self }
23552355}
23562356~~~~
@@ -2600,13 +2600,13 @@ A small number of traits in `std` and `extra` can have implementations
26002600that can be automatically derived. These instances are specified by
26012601placing the ` deriving ` attribute on a data type declaration. For
26022602example, the following will mean that ` Circle ` has an implementation
2603- for ` Eq ` and can be used with the equality operators, and that a value
2603+ for ` PartialEq ` and can be used with the equality operators, and that a value
26042604of type ` ABC ` can be randomly generated and converted to a string:
26052605
26062606~~~
26072607extern crate rand;
26082608
2609- #[deriving(Eq )]
2609+ #[deriving(PartialEq )]
26102610struct Circle { radius: f64 }
26112611
26122612#[deriving(Rand, Show)]
@@ -2618,7 +2618,7 @@ fn main() {
26182618}
26192619~~~
26202620
2621- The full list of derivable traits is ` Eq ` , ` TotalEq ` , ` Ord ` ,
2621+ The full list of derivable traits is ` PartialEq ` , ` TotalEq ` , ` Ord ` ,
26222622` TotalOrd ` , ` Encodable ` , ` Decodable ` , ` Clone ` ,
26232623` Hash ` , ` Rand ` , ` Default ` , ` Zero ` , ` FromPrimitive ` and ` Show ` .
26242624
0 commit comments