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]
This commit is contained in:
Alex Crichton 2014-05-01 10:51:30 -07:00
parent e4271cae54
commit f12b51705b

View File

@ -138,11 +138,9 @@
//! }
//! ```
use any::Any;
use cmp::{Eq, TotalEq, TotalOrd};
use default::Default;
use iter::{Iterator, DoubleEndedIterator, FromIterator, ExactSize};
use kinds::Send;
use mem;
use slice;
@ -238,7 +236,7 @@ impl<T> Option<T> {
///
/// Fails if the value is a `None` with a custom failure message provided by `msg`.
#[inline]
pub fn expect<M: Any + Send>(self, msg: M) -> T {
pub fn expect(self, msg: &str) -> T {
match self {
Some(val) => val,
None => fail!(msg),