Skip to content

Commit f12b517

Browse files
committed
core: Remove generics from Option::expect
The prospects of a generic failure function such as this existing in libcore are bleak, due to monomorphization not working across the crate boundary, and allocation into a ~Any is not allowed in libcore. The argument to expect() is now &str instead of <M: Send + Any> [breaking-change]
1 parent e4271ca commit f12b517

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/libcore/option.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,9 @@
138138
//! }
139139
//! ```
140140
141-
use any::Any;
142141
use cmp::{Eq, TotalEq, TotalOrd};
143142
use default::Default;
144143
use iter::{Iterator, DoubleEndedIterator, FromIterator, ExactSize};
145-
use kinds::Send;
146144
use mem;
147145
use slice;
148146

@@ -238,7 +236,7 @@ impl<T> Option<T> {
238236
///
239237
/// Fails if the value is a `None` with a custom failure message provided by `msg`.
240238
#[inline]
241-
pub fn expect<M: Any + Send>(self, msg: M) -> T {
239+
pub fn expect(self, msg: &str) -> T {
242240
match self {
243241
Some(val) => val,
244242
None => fail!(msg),

0 commit comments

Comments
 (0)