From f12b51705b064bbbeb86ad65663de476d07ad51f Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 1 May 2014 10:51:30 -0700 Subject: [PATCH] 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 [breaking-change] --- src/libcore/option.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 31a452553e5..84da65f90be 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -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 Option { /// /// Fails if the value is a `None` with a custom failure message provided by `msg`. #[inline] - pub fn expect(self, msg: M) -> T { + pub fn expect(self, msg: &str) -> T { match self { Some(val) => val, None => fail!(msg),