}
}
-impl Box<Any> {
+impl Box<dyn Any> {
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
/// Attempt to downcast the box to a concrete type.
/// print_if_string(Box::new(0i8));
/// }
/// ```
- pub fn downcast<T: Any>(self) -> Result<Box<T>, Box<Any>> {
+ pub fn downcast<T: Any>(self) -> Result<Box<T>, Box<dyn Any>> {
if self.is::<T>() {
unsafe {
- let raw: *mut Any = Box::into_raw(self);
+ let raw: *mut dyn Any = Box::into_raw(self);
Ok(Box::from_raw(raw as *mut T))
}
} else {
}
}
-impl Box<Any + Send> {
+impl Box<dyn Any + Send> {
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
/// Attempt to downcast the box to a concrete type.
/// print_if_string(Box::new(0i8));
/// }
/// ```
- pub fn downcast<T: Any>(self) -> Result<Box<T>, Box<Any + Send>> {
- <Box<Any>>::downcast(self).map_err(|s| unsafe {
+ pub fn downcast<T: Any>(self) -> Result<Box<T>, Box<dyn Any + Send>> {
+ <Box<dyn Any>>::downcast(self).map_err(|s| unsafe {
// reapply the Send marker
- Box::from_raw(Box::into_raw(s) as *mut (Any + Send))
+ Box::from_raw(Box::into_raw(s) as *mut (dyn Any + Send))
})
}
}
#[unstable(feature = "fnbox",
reason = "will be deprecated if and when `Box<FnOnce>` becomes usable", issue = "28796")]
-impl<'a, A, R> FnOnce<A> for Box<FnBox<A, Output = R> + 'a> {
+impl<'a, A, R> FnOnce<A> for Box<dyn FnBox<A, Output = R> + 'a> {
type Output = R;
extern "rust-call" fn call_once(self, args: A) -> R {
#[unstable(feature = "fnbox",
reason = "will be deprecated if and when `Box<FnOnce>` becomes usable", issue = "28796")]
-impl<'a, A, R> FnOnce<A> for Box<FnBox<A, Output = R> + Send + 'a> {
+impl<'a, A, R> FnOnce<A> for Box<dyn FnBox<A, Output = R> + Send + 'a> {
type Output = R;
extern "rust-call" fn call_once(self, args: A) -> R {
}
}
-impl Rc<Any> {
+impl Rc<dyn Any> {
#[inline]
#[stable(feature = "rc_downcast", since = "1.29.0")]
/// Attempt to downcast the `Rc<Any>` to a concrete type.
/// print_if_string(Rc::new(0i8));
/// }
/// ```
- pub fn downcast<T: Any>(self) -> Result<Rc<T>, Rc<Any>> {
+ pub fn downcast<T: Any>(self) -> Result<Rc<T>, Rc<dyn Any>> {
if (*self).is::<T>() {
let ptr = self.ptr.cast::<RcBox<T>>();
forget(self);