Skip to content

Commit ff536f3

Browse files
committed
core: Don't require copyable options where possible. Closes #2636
1 parent f87c28b commit ff536f3

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/libcore/option.rs

+10-9
Original file line numberDiff line numberDiff line change
@@ -87,20 +87,26 @@ pure fn unwrap<T>(-opt: option<T>) -> T unsafe {
8787
ret liberated_value;
8888
}
8989

90-
impl extensions<T:copy> for option<T> {
90+
impl extensions<T> for option<T> {
9191
#[doc = "
9292
Update an optional value by optionally running its content through a
9393
function that returns an option.
9494
"]
9595
fn chain<U>(f: fn(T) -> option<U>) -> option<U> { chain(self, f) }
96-
#[doc = "Returns the contained value or a default"]
97-
fn get_default(def: T) -> T { get_default(self, def) }
9896
#[doc = "Applies a function to the contained value or returns a default"]
9997
fn map_default<U: copy>(def: U, f: fn(T) -> U) -> U
10098
{ map_default(self, def, f) }
10199
#[doc = "Performs an operation on the contained value or does nothing"]
102100
fn iter(f: fn(T)) { iter(self, f) }
101+
#[doc = "Returns true if the option equals `none`"]
102+
fn is_none() -> bool { is_none(self) }
103+
#[doc = "Returns true if the option contains some value"]
104+
fn is_some() -> bool { is_some(self) }
105+
#[doc = "Maps a `some` value from one type to another"]
106+
fn map<U:copy>(f: fn(T) -> U) -> option<U> { map(self, f) }
107+
}
103108

109+
impl extensions<T: copy> for option<T> {
104110
#[doc = "
105111
Gets the value out of an option
106112
@@ -109,12 +115,7 @@ impl extensions<T:copy> for option<T> {
109115
Fails if the value equals `none`
110116
"]
111117
fn get() -> T { get(self) }
112-
#[doc = "Returns true if the option equals `none`"]
113-
fn is_none() -> bool { is_none(self) }
114-
#[doc = "Returns true if the option contains some value"]
115-
fn is_some() -> bool { is_some(self) }
116-
#[doc = "Maps a `some` value from one type to another"]
117-
fn map<U:copy>(f: fn(T) -> U) -> option<U> { map(self, f) }
118+
fn get_default(def: T) -> T { get_default(self, def) }
118119
}
119120

120121
#[test]

0 commit comments

Comments
 (0)