Skip to content

Commit 60ea6d6

Browse files
committed
Convert various inner doc-comments to outer doc-comments
1 parent 728fe77 commit 60ea6d6

File tree

4 files changed

+30
-55
lines changed

4 files changed

+30
-55
lines changed

src/libcore/cmp.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,11 @@ totalord_impl!(uint)
127127

128128
totalord_impl!(char)
129129

130+
/// Compares (a1, b1) against (a2, b2), where the a values are more significant.
130131
pub fn cmp2<A:TotalOrd,B:TotalOrd>(
131132
a1: &A, b1: &B,
132133
a2: &A, b2: &B) -> Ordering
133134
{
134-
//! Compares (a1, b1) against (a2, b2), where the a values are more significant.
135-
136135
match a1.cmp(a2) {
137136
Less => Less,
138137
Greater => Greater,

src/libcore/either.rs

+22-40
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,22 @@ pub enum Either<T, U> {
2626
Right(U)
2727
}
2828

29+
/// Applies a function based on the given either value
30+
///
31+
/// If `value` is left(T) then `f_left` is applied to its contents, if
32+
/// `value` is right(U) then `f_right` is applied to its contents, and the
33+
/// result is returned.
2934
#[inline(always)]
3035
pub fn either<T, U, V>(f_left: &fn(&T) -> V,
3136
f_right: &fn(&U) -> V, value: &Either<T, U>) -> V {
32-
/*!
33-
* Applies a function based on the given either value
34-
*
35-
* If `value` is left(T) then `f_left` is applied to its contents, if
36-
* `value` is right(U) then `f_right` is applied to its contents, and the
37-
* result is returned.
38-
*/
39-
4037
match *value {
4138
Left(ref l) => f_left(l),
4239
Right(ref r) => f_right(r)
4340
}
4441
}
4542

43+
/// Extracts from a vector of either all the left values
4644
pub fn lefts<T:Copy,U>(eithers: &[Either<T, U>]) -> ~[T] {
47-
//! Extracts from a vector of either all the left values
48-
4945
do vec::build_sized(eithers.len()) |push| {
5046
for eithers.each |elt| {
5147
match *elt {
@@ -56,9 +52,8 @@ pub fn lefts<T:Copy,U>(eithers: &[Either<T, U>]) -> ~[T] {
5652
}
5753
}
5854

55+
/// Extracts from a vector of either all the right values
5956
pub fn rights<T, U: Copy>(eithers: &[Either<T, U>]) -> ~[U] {
60-
//! Extracts from a vector of either all the right values
61-
6257
do vec::build_sized(eithers.len()) |push| {
6358
for eithers.each |elt| {
6459
match *elt {
@@ -69,15 +64,11 @@ pub fn rights<T, U: Copy>(eithers: &[Either<T, U>]) -> ~[U] {
6964
}
7065
}
7166

72-
pub fn partition<T, U>(eithers: ~[Either<T, U>])
73-
-> (~[T], ~[U]) {
74-
/*!
75-
* Extracts from a vector of either all the left values and right values
76-
*
77-
* Returns a structure containing a vector of left values and a vector of
78-
* right values.
79-
*/
80-
67+
/// Extracts from a vector of either all the left values and right values
68+
///
69+
/// Returns a structure containing a vector of left values and a vector of
70+
/// right values.
71+
pub fn partition<T, U>(eithers: ~[Either<T, U>]) -> (~[T], ~[U]) {
8172
let mut lefts: ~[T] = ~[];
8273
let mut rights: ~[U] = ~[];
8374
do vec::consume(eithers) |_i, elt| {
@@ -89,60 +80,51 @@ pub fn partition<T, U>(eithers: ~[Either<T, U>])
8980
return (lefts, rights);
9081
}
9182

83+
/// Flips between left and right of a given either
9284
#[inline(always)]
9385
pub fn flip<T, U>(eith: Either<T, U>) -> Either<U, T> {
94-
//! Flips between left and right of a given either
95-
9686
match eith {
9787
Right(r) => Left(r),
9888
Left(l) => Right(l)
9989
}
10090
}
10191

92+
/// Converts either::t to a result::t
93+
///
94+
/// Converts an `either` type to a `result` type, making the "right" choice
95+
/// an ok result, and the "left" choice a fail
10296
#[inline(always)]
103-
pub fn to_result<T, U>(eith: Either<T, U>)
104-
-> Result<U, T> {
105-
/*!
106-
* Converts either::t to a result::t
107-
*
108-
* Converts an `either` type to a `result` type, making the "right" choice
109-
* an ok result, and the "left" choice a fail
110-
*/
111-
97+
pub fn to_result<T, U>(eith: Either<T, U>) -> Result<U, T> {
11298
match eith {
11399
Right(r) => result::Ok(r),
114100
Left(l) => result::Err(l)
115101
}
116102
}
117103

104+
/// Checks whether the given value is a left
118105
#[inline(always)]
119106
pub fn is_left<T, U>(eith: &Either<T, U>) -> bool {
120-
//! Checks whether the given value is a left
121-
122107
match *eith { Left(_) => true, _ => false }
123108
}
124109

110+
/// Checks whether the given value is a right
125111
#[inline(always)]
126112
pub fn is_right<T, U>(eith: &Either<T, U>) -> bool {
127-
//! Checks whether the given value is a right
128-
129113
match *eith { Right(_) => true, _ => false }
130114
}
131115

116+
/// Retrieves the value in the left branch. Fails if the either is Right.
132117
#[inline(always)]
133118
pub fn unwrap_left<T,U>(eith: Either<T,U>) -> T {
134-
//! Retrieves the value in the left branch. Fails if the either is Right.
135-
136119
match eith {
137120
Left(x) => x,
138121
Right(_) => fail!("either::unwrap_left Right")
139122
}
140123
}
141124

125+
/// Retrieves the value in the right branch. Fails if the either is Left.
142126
#[inline(always)]
143127
pub fn unwrap_right<T,U>(eith: Either<T,U>) -> U {
144-
//! Retrieves the value in the right branch. Fails if the either is Left.
145-
146128
match eith {
147129
Right(x) => x,
148130
Left(_) => fail!("either::unwrap_right Left")

src/libcore/managed.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,16 @@ pub mod raw {
3535

3636
}
3737

38+
/// Determine if two shared boxes point to the same object
3839
#[inline(always)]
3940
pub fn ptr_eq<T>(a: @T, b: @T) -> bool {
40-
//! Determine if two shared boxes point to the same object
4141
let a_ptr: *T = to_unsafe_ptr(&*a), b_ptr: *T = to_unsafe_ptr(&*b);
4242
a_ptr == b_ptr
4343
}
4444

45+
/// Determine if two mutable shared boxes point to the same object
4546
#[inline(always)]
4647
pub fn mut_ptr_eq<T>(a: @mut T, b: @mut T) -> bool {
47-
//! Determine if two mutable shared boxes point to the same object
4848
let a_ptr: *T = to_unsafe_ptr(&*a), b_ptr: *T = to_unsafe_ptr(&*b);
4949
a_ptr == b_ptr
5050
}

src/libcore/option.rs

+5-11
Original file line numberDiff line numberDiff line change
@@ -182,34 +182,28 @@ pub impl<T> Option<T> {
182182
#[inline(always)]
183183
fn is_some(&const self) -> bool { !self.is_none() }
184184

185+
/// Update an optional value by optionally running its content through a
186+
/// function that returns an option.
185187
#[inline(always)]
186188
fn chain<U>(self, f: &fn(t: T) -> Option<U>) -> Option<U> {
187-
/*!
188-
* Update an optional value by optionally running its content through a
189-
* function that returns an option.
190-
*/
191189

192190
match self {
193191
Some(t) => f(t),
194192
None => None
195193
}
196194
}
197195

196+
/// Returns the leftmost Some() value, or None if both are None.
198197
#[inline(always)]
199198
fn or(self, optb: Option<T>) -> Option<T> {
200-
/*!
201-
* Returns the leftmost Some() value, or None if both are None.
202-
*/
203199
match self {
204200
Some(opta) => Some(opta),
205201
_ => optb
206202
}
207203
}
208204

209-
/**
210-
* Update an optional value by optionally running its content by reference
211-
* through a function that returns an option.
212-
*/
205+
/// Update an optional value by optionally running its content by reference
206+
/// through a function that returns an option.
213207
#[inline(always)]
214208
fn chain_ref<'a, U>(&'a self, f: &fn(x: &'a T) -> Option<U>) -> Option<U> {
215209
match *self { Some(ref x) => f(x), None => None }

0 commit comments

Comments
 (0)