Skip to content

Commit

Permalink
Change option::expect to not require a Copy bound, and move instead.
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian J. Burg committed Nov 9, 2012
1 parent 1702024 commit a5718ba
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/libcore/option.rs
Expand Up @@ -85,16 +85,17 @@ pub pure fn get_ref<T>(opt: &r/Option<T>) -> &r/T {
}
}

pub pure fn expect<T: Copy>(opt: Option<T>, reason: ~str) -> T {
pub pure fn expect<T>(opt: Option<T>, reason: ~str) -> T {
/*!
* Gets the value out of an option, printing a specified message on
* failure
* Gets the value out of an option without copying, printing a
* specified message on failure.
*
* # Failure
*
* Fails if the value equals `none`
*/
match opt { Some(copy x) => x, None => fail reason }
if opt.is_some() { move option::unwrap(move opt) }
else { fail reason }
}

pub pure fn map<T, U>(opt: &Option<T>, f: fn(x: &T) -> U) -> Option<U> {
Expand Down

3 comments on commit a5718ba

@am0d
Copy link
Contributor

@am0d am0d commented on a5718ba Nov 14, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit is causing a crash in the compiler for me, but I'm not really sure where. I did a git bisect and found that this was the commit causing the crash.
I only know that the crash is happening in the runtime somewhere - any hints on where to start looking for this?

@brson
Copy link
Contributor

@brson brson commented on a5718ba Nov 14, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@am0d That's quite surprising! Please file an issue. Usually the first thing I do is run under gdb and get a backtrace.

@burg
Copy link

@burg burg commented on a5718ba Nov 14, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😱

Please sign in to comment.