Skip to content

Commit 85129e2

Browse files
committed
Remove use of block comments in src/libstd/cmp.rs
1 parent cf83ff8 commit 85129e2

File tree

1 file changed

+72
-84
lines changed

1 file changed

+72
-84
lines changed

src/libstd/cmp.rs

+72-84
Original file line numberDiff line numberDiff line change
@@ -8,50 +8,47 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
/*!
12-
13-
Defines the `Ord` and `Eq` comparison traits.
14-
15-
This module defines both `Ord` and `Eq` traits which are used by the compiler
16-
to implement comparison operators.
17-
Rust programs may implement `Ord` to overload the `<`, `<=`, `>`, and `>=` operators,
18-
and may implement `Eq` to overload the `==` and `!=` operators.
19-
20-
For example, to define a type with a customized definition for the Eq operators,
21-
you could do the following:
22-
23-
```rust
24-
// Our type.
25-
struct SketchyNum {
26-
num : int
27-
}
28-
29-
// Our implementation of `Eq` to support `==` and `!=`.
30-
impl Eq for SketchyNum {
31-
// Our custom eq allows numbers which are near eachother to be equal! :D
32-
fn eq(&self, other: &SketchyNum) -> bool {
33-
(self.num - other.num).abs() < 5
34-
}
35-
}
36-
37-
// Now these binary operators will work when applied!
38-
assert!(SketchyNum {num: 37} == SketchyNum {num: 34});
39-
assert!(SketchyNum {num: 25} != SketchyNum {num: 57});
40-
```
41-
42-
*/
43-
44-
/**
45-
* Trait for values that can be compared for equality and inequality.
46-
*
47-
* This trait allows partial equality, where types can be unordered instead of strictly equal or
48-
* unequal. For example, with the built-in floating-point types `a == b` and `a != b` will both
49-
* evaluate to false if either `a` or `b` is NaN (cf. IEEE 754-2008 section 5.11).
50-
*
51-
* Eq only requires the `eq` method to be implemented; `ne` is its negation by default.
52-
*
53-
* Eventually, this will be implemented by default for types that implement `TotalEq`.
54-
*/
11+
//! Defines the `Ord` and `Eq` comparison traits.
12+
//!
13+
//! This module defines both `Ord` and `Eq` traits which are used by the
14+
//! compiler to implement comparison operators. Rust programs may implement
15+
//!`Ord` to overload the `<`, `<=`, `>`, and `>=` operators, and may implement
16+
//! `Eq` to overload the `==` and `!=` operators.
17+
//!
18+
//! For example, to define a type with a customized definition for the Eq
19+
//! operators, you could do the following:
20+
//!
21+
//! ```rust
22+
//! // Our type.
23+
//! struct SketchyNum {
24+
//! num : int
25+
//! }
26+
//!
27+
//! // Our implementation of `Eq` to support `==` and `!=`.
28+
//! impl Eq for SketchyNum {
29+
//! // Our custom eq allows numbers which are near eachother to be equal! :D
30+
//! fn eq(&self, other: &SketchyNum) -> bool {
31+
//! (self.num - other.num).abs() < 5
32+
//! }
33+
//! }
34+
//!
35+
//! // Now these binary operators will work when applied!
36+
//! assert!(SketchyNum {num: 37} == SketchyNum {num: 34});
37+
//! assert!(SketchyNum {num: 25} != SketchyNum {num: 57});
38+
//! ```
39+
40+
/// Trait for values that can be compared for equality and inequality.
41+
///
42+
/// This trait allows partial equality, where types can be unordered instead of
43+
/// strictly equal or unequal. For example, with the built-in floating-point
44+
/// types `a == b` and `a != b` will both evaluate to false if either `a` or
45+
/// `b` is NaN (cf. IEEE 754-2008 section 5.11).
46+
///
47+
/// Eq only requires the `eq` method to be implemented; `ne` is its negation by
48+
/// default.
49+
///
50+
/// Eventually, this will be implemented by default for types that implement
51+
/// `TotalEq`.
5552
#[lang="eq"]
5653
pub trait Eq {
5754
/// This method tests for `self` and `other` values to be equal, and is used by `==`.
@@ -62,18 +59,15 @@ pub trait Eq {
6259
fn ne(&self, other: &Self) -> bool { !self.eq(other) }
6360
}
6461

65-
/**
66-
* Trait for equality comparisons which are [equivalence relations](
67-
* https://en.wikipedia.org/wiki/Equivalence_relation).
68-
*
69-
* This means, that in addition to `a == b` and `a != b` being strict inverses,
70-
* the equality must be (for all `a`, `b` and `c`):
71-
*
72-
* - reflexive: `a == a`;
73-
* - symmetric: `a == b` implies `b == a`; and
74-
* - transitive: `a == b` and `b == c` implies `a == c`.
75-
*/
76-
62+
/// Trait for equality comparisons which are [equivalence relations](
63+
/// https://en.wikipedia.org/wiki/Equivalence_relation).
64+
///
65+
/// This means, that in addition to `a == b` and `a != b` being strict
66+
/// inverses, the equality must be (for all `a`, `b` and `c`):
67+
///
68+
/// - reflexive: `a == a`;
69+
/// - symmetric: `a == b` implies `b == a`; and
70+
/// - transitive: `a == b` and `b == c` implies `a == c`.
7771
pub trait TotalEq: Eq {
7872
// FIXME #13101: this method is used solely by #[deriving] to
7973
// assert that every component of a type implements #[deriving]
@@ -122,17 +116,15 @@ pub enum Ordering {
122116
Greater = 1
123117
}
124118

125-
/**
126-
* Trait for types that form a [total order](
127-
* https://en.wikipedia.org/wiki/Total_order).
128-
*
129-
* An order is a total order if it is (for all `a`, `b` and `c`):
130-
*
131-
* - total and antisymmetric: exactly one of `a < b`, `a == b` or `a > b`
132-
* is true; and
133-
* - transitive, `a < b` and `b < c` implies `a < c`. The same must hold for
134-
* both `==` and `>`.
135-
*/
119+
/// Trait for types that form a [total order](
120+
/// https://en.wikipedia.org/wiki/Total_order).
121+
///
122+
/// An order is a total order if it is (for all `a`, `b` and `c`):
123+
///
124+
/// - total and antisymmetric: exactly one of `a < b`, `a == b` or `a > b` is
125+
/// true; and
126+
/// - transitive, `a < b` and `b < c` implies `a < c`. The same must hold for
127+
/// both `==` and `>`.
136128
pub trait TotalOrd: TotalEq + Ord {
137129
/// This method returns an ordering between `self` and `other` values.
138130
///
@@ -189,13 +181,11 @@ totalord_impl!(uint)
189181

190182
totalord_impl!(char)
191183

192-
/**
193-
* Combine orderings, lexically.
194-
*
195-
* For example for a type `(int, int)`, two comparisons could be done.
196-
* If the first ordering is different, the first ordering is all that must be returned.
197-
* If the first ordering is equal, then second ordering is returned.
198-
*/
184+
/// Combine orderings, lexically.
185+
///
186+
/// For example for a type `(int, int)`, two comparisons could be done.
187+
/// If the first ordering is different, the first ordering is all that must be returned.
188+
/// If the first ordering is equal, then second ordering is returned.
199189
#[inline]
200190
pub fn lexical_ordering(o1: Ordering, o2: Ordering) -> Ordering {
201191
match o1 {
@@ -204,16 +194,14 @@ pub fn lexical_ordering(o1: Ordering, o2: Ordering) -> Ordering {
204194
}
205195
}
206196

207-
/**
208-
* Trait for values that can be compared for a sort-order.
209-
*
210-
* Ord only requires implementation of the `lt` method,
211-
* with the others generated from default implementations.
212-
*
213-
* However it remains possible to implement the others separately,
214-
* for compatibility with floating-point NaN semantics
215-
* (cf. IEEE 754-2008 section 5.11).
216-
*/
197+
/// Trait for values that can be compared for a sort-order.
198+
///
199+
/// Ord only requires implementation of the `lt` method,
200+
/// with the others generated from default implementations.
201+
///
202+
/// However it remains possible to implement the others separately,
203+
/// for compatibility with floating-point NaN semantics
204+
/// (cf. IEEE 754-2008 section 5.11).
217205
#[lang="ord"]
218206
pub trait Ord: Eq {
219207
/// This method tests less than (for `self` and `other`) and is used by the `<` operator.

0 commit comments

Comments
 (0)