Skip to content

Commit c4338a1

Browse files
committed
---
yaml --- r: 41716 b: refs/heads/master c: 38315fb h: refs/heads/master v: v3
1 parent 8d072eb commit c4338a1

File tree

3 files changed

+3
-44
lines changed

3 files changed

+3
-44
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: ac85bf356f3674ed0e0e79668b384141d38e0efe
2+
refs/heads/master: 38315fb007939e0fcaad825a5e08b9ab729cd5bd
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 2f46b763da2c098913884f101b6d71d69af41b49
55
refs/heads/try: 3d5418789064fdb463e872a4e651af1c628a3650

trunk/doc/tutorial-macros.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ to transcribe into the macro expansion; its type need not be repeated.
115115
The right-hand side must be enclosed by delimiters, which are ignored by the
116116
transcriber (therefore `() => ((1,2,3))` is a macro that expands to a tuple
117117
expression, `() => (let $x=$val)` is a macro that expands to a statement, and
118-
`() => (1,2,3)` is a macro that expands to a syntax errror).
118+
`() => (1,2,3)` is a macro that expands to a syntax error).
119119

120120
Except for permissibility of `$name` (and `$(...)*`, discussed below), the
121121
right-hand side of a macro definition is ordinary Rust syntax. In particular,

trunk/src/libcore/option.rs

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ pub pure fn map_consume<T, U>(opt: Option<T>,
114114
* As `map`, but consumes the option and gives `f` ownership to avoid
115115
* copying.
116116
*/
117-
match opt { None => None, Some(v) => Some(f(v)) }
117+
if opt.is_some() { Some(f(option::unwrap(move opt))) } else { None }
118118
}
119119

120120
pub pure fn chain<T, U>(opt: Option<T>,
@@ -264,42 +264,12 @@ impl<T> Option<T> {
264264
#[inline(always)]
265265
pure fn map<U>(&self, f: fn(x: &T) -> U) -> Option<U> { map(self, f) }
266266

267-
/// As `map`, but consumes the option and gives `f` ownership to avoid
268-
/// copying.
269-
#[inline(always)]
270-
pure fn map_consume<U>(self, f: fn(v: T) -> U) -> Option<U> {
271-
map_consume(self, f)
272-
}
273-
274267
/// Applies a function to the contained value or returns a default
275268
#[inline(always)]
276269
pure fn map_default<U>(&self, def: U, f: fn(x: &T) -> U) -> U {
277270
map_default(self, move def, f)
278271
}
279272

280-
/// As `map_default`, but consumes the option and gives `f`
281-
/// ownership to avoid copying.
282-
#[inline(always)]
283-
pure fn map_consume_default<U>(self, def: U, f: fn(v: T) -> U) -> U {
284-
match self { None => def, Some(v) => f(v) }
285-
}
286-
287-
/// Apply a function to the contained value or do nothing
288-
fn mutate(&mut self, f: fn(T) -> T) {
289-
if self.is_some() {
290-
*self = Some(f(self.swap_unwrap()));
291-
}
292-
}
293-
294-
/// Apply a function to the contained value or set it to a default
295-
fn mutate_default(&mut self, def: T, f: fn(T) -> T) {
296-
if self.is_some() {
297-
*self = Some(f(self.swap_unwrap()));
298-
} else {
299-
*self = Some(def);
300-
}
301-
}
302-
303273
/// Performs an operation on the contained value by reference
304274
#[inline(always)]
305275
pure fn iter(&self, f: fn(x: &T)) { iter(self, f) }
@@ -331,17 +301,6 @@ impl<T> Option<T> {
331301
#[inline(always)]
332302
pure fn unwrap(self) -> T { unwrap(self) }
333303

334-
/**
335-
* The option dance. Moves a value out of an option type and returns it,
336-
* replacing the original with `None`.
337-
*
338-
* # Failure
339-
*
340-
* Fails if the value equals `None`.
341-
*/
342-
#[inline(always)]
343-
fn swap_unwrap(&mut self) -> T { swap_unwrap(self) }
344-
345304
/**
346305
* Gets the value out of an option, printing a specified message on
347306
* failure

0 commit comments

Comments
 (0)