#[unstable(feature = "option_expect_none", reason = "newly added", issue = "0")]
pub fn expect_none(self, msg: &str) {
if let Some(val) = self {
- expect_none_failed(msg, val);
+ expect_none_failed(msg, &val);
}
}
#[unstable(feature = "option_unwrap_none", reason = "newly added", issue = "0")]
pub fn unwrap_none(self) {
if let Some(val) = self {
- expect_none_failed("called `Option::unwrap_none()` on a `Some` value", val);
+ expect_none_failed("called `Option::unwrap_none()` on a `Some` value", &val);
}
}
}
// This is a separate function to reduce the code size of .expect_none() itself.
#[inline(never)]
#[cold]
-fn expect_none_failed<T: fmt::Debug>(msg: &str, value: T) -> ! {
+fn expect_none_failed(msg: &str, value: &dyn fmt::Debug) -> ! {
panic!("{}: {:?}", msg, value)
}
pub fn unwrap(self) -> T {
match self {
Ok(t) => t,
- Err(e) => unwrap_failed("called `Result::unwrap()` on an `Err` value", e),
+ Err(e) => unwrap_failed("called `Result::unwrap()` on an `Err` value", &e),
}
}
pub fn expect(self, msg: &str) -> T {
match self {
Ok(t) => t,
- Err(e) => unwrap_failed(msg, e),
+ Err(e) => unwrap_failed(msg, &e),
}
}
}
#[stable(feature = "rust1", since = "1.0.0")]
pub fn unwrap_err(self) -> E {
match self {
- Ok(t) => unwrap_failed("called `Result::unwrap_err()` on an `Ok` value", t),
+ Ok(t) => unwrap_failed("called `Result::unwrap_err()` on an `Ok` value", &t),
Err(e) => e,
}
}
#[stable(feature = "result_expect_err", since = "1.17.0")]
pub fn expect_err(self, msg: &str) -> E {
match self {
- Ok(t) => unwrap_failed(msg, t),
+ Ok(t) => unwrap_failed(msg, &t),
Err(e) => e,
}
}
// This is a separate function to reduce the code size of the methods
#[inline(never)]
#[cold]
-fn unwrap_failed<E: fmt::Debug>(msg: &str, error: E) -> ! {
+fn unwrap_failed(msg: &str, error: &dyn fmt::Debug) -> ! {
panic!("{}: {:?}", msg, error)
}