Skip to content

Commit a1b827d

Browse files
committed
---
yaml --- r: 69343 b: refs/heads/auto c: ba9c3eb h: refs/heads/master i: 69341: 55f3231 69339: 36cf17d 69335: ebadbab 69327: 90b9434 69311: d2a8fed v: v3
1 parent 780ae7d commit a1b827d

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: 6f253419eeb079d5c84f327dd598ab37102168a1
17+
refs/heads/auto: ba9c3ebc02716252cf46944e4dd3a866cc51947c
1818
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1919
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c

branches/auto/src/libstd/option.rs

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,13 @@ impl<T> Option<T> {
118118
}
119119
}
120120

121-
/// Returns true if the option equals `none`
121+
/// Returns true if the option equals `None`
122122
#[inline]
123123
pub fn is_none(&self) -> bool {
124124
match *self { None => true, Some(_) => false }
125125
}
126126

127-
/// Returns true if the option contains some value
127+
/// Returns true if the option contains a `Some` value
128128
#[inline]
129129
pub fn is_some(&self) -> bool { !self.is_none() }
130130

@@ -158,6 +158,17 @@ impl<T> Option<T> {
158158
}
159159
}
160160

161+
/// Update an optional value by optionally running its content by mut reference
162+
/// through a function that returns an option.
163+
#[inline]
164+
pub fn chain_mut_ref<'a, U>(&'a mut self, f: &fn(x: &'a mut T) -> Option<U>)
165+
-> Option<U> {
166+
match *self {
167+
Some(ref mut x) => f(x),
168+
None => None
169+
}
170+
}
171+
161172
/// Filters an optional value using given function.
162173
#[inline(always)]
163174
pub fn filtered(self, f: &fn(t: &T) -> bool) -> Option<T> {
@@ -167,19 +178,19 @@ impl<T> Option<T> {
167178
}
168179
}
169180

170-
/// Maps a `some` value from one type to another by reference
181+
/// Maps a `Some` value from one type to another by reference
171182
#[inline]
172183
pub fn map<'a, U>(&'a self, f: &fn(&'a T) -> U) -> Option<U> {
173184
match *self { Some(ref x) => Some(f(x)), None => None }
174185
}
175186

176-
/// Maps a `some` value from one type to another by a mutable reference
187+
/// Maps a `Some` value from one type to another by a mutable reference
177188
#[inline]
178189
pub fn map_mut<'a, U>(&'a mut self, f: &fn(&'a mut T) -> U) -> Option<U> {
179190
match *self { Some(ref mut x) => Some(f(x)), None => None }
180191
}
181192

182-
/// Maps a `some` value from one type to another by a mutable reference,
193+
/// Maps a `Some` value from one type to another by a mutable reference,
183194
/// or returns a default value.
184195
#[inline]
185196
pub fn map_mut_default<'a, U>(&'a mut self, def: U, f: &fn(&'a mut T) -> U) -> U {
@@ -260,7 +271,7 @@ impl<T> Option<T> {
260271
pub fn get_ref<'a>(&'a self) -> &'a T {
261272
match *self {
262273
Some(ref x) => x,
263-
None => fail!("option::get_ref none")
274+
None => fail!("option::get_ref None")
264275
}
265276
}
266277

@@ -282,7 +293,7 @@ impl<T> Option<T> {
282293
pub fn get_mut_ref<'a>(&'a mut self) -> &'a mut T {
283294
match *self {
284295
Some(ref mut x) => x,
285-
None => fail!("option::get_mut_ref none")
296+
None => fail!("option::get_mut_ref None")
286297
}
287298
}
288299

@@ -306,7 +317,7 @@ impl<T> Option<T> {
306317
*/
307318
match self {
308319
Some(x) => x,
309-
None => fail!("option::unwrap none")
320+
None => fail!("option::unwrap None")
310321
}
311322
}
312323

@@ -320,7 +331,7 @@ impl<T> Option<T> {
320331
*/
321332
#[inline]
322333
pub fn take_unwrap(&mut self) -> T {
323-
if self.is_none() { fail!("option::take_unwrap none") }
334+
if self.is_none() { fail!("option::take_unwrap None") }
324335
self.take().unwrap()
325336
}
326337

@@ -330,7 +341,7 @@ impl<T> Option<T> {
330341
*
331342
* # Failure
332343
*
333-
* Fails if the value equals `none`
344+
* Fails if the value equals `None`
334345
*/
335346
#[inline]
336347
pub fn expect(self, reason: &str) -> T {
@@ -358,7 +369,7 @@ impl<T> Option<T> {
358369
pub fn get(self) -> T {
359370
match self {
360371
Some(x) => return x,
361-
None => fail!("option::get none")
372+
None => fail!("option::get None")
362373
}
363374
}
364375

@@ -368,7 +379,7 @@ impl<T> Option<T> {
368379
match self { Some(x) => x, None => def }
369380
}
370381

371-
/// Applies a function zero or more times until the result is none.
382+
/// Applies a function zero or more times until the result is None.
372383
#[inline]
373384
pub fn while_some(self, blk: &fn(v: T) -> Option<T>) {
374385
let mut opt = self;

0 commit comments

Comments
 (0)