Bound Any with 'static
This bound is already implicit through the AnyPrivate trait, but since it is not explicit, you still have to write Box<Any + 'static>, even though Any can only be 'static. Introducing the 'static bound here makes this bound explicit, making Box<Any> legal.
This commit is contained in:
parent
88d1a22f76
commit
0cf60b6bb8
1 changed files with 3 additions and 3 deletions
|
@ -91,7 +91,7 @@ pub enum Void { }
|
||||||
/// Every type with no non-`'static` references implements `Any`, so `Any` can
|
/// Every type with no non-`'static` references implements `Any`, so `Any` can
|
||||||
/// be used as a trait object to emulate the effects dynamic typing.
|
/// be used as a trait object to emulate the effects dynamic typing.
|
||||||
#[stable]
|
#[stable]
|
||||||
pub trait Any: AnyPrivate {}
|
pub trait Any: AnyPrivate + 'static {}
|
||||||
|
|
||||||
/// An inner trait to ensure that only this module can call `get_type_id()`.
|
/// An inner trait to ensure that only this module can call `get_type_id()`.
|
||||||
pub trait AnyPrivate {
|
pub trait AnyPrivate {
|
||||||
|
@ -132,7 +132,7 @@ pub trait AnyRefExt<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[stable]
|
#[stable]
|
||||||
impl<'a> AnyRefExt<'a> for &'a Any+'a {
|
impl<'a> AnyRefExt<'a> for &'a Any {
|
||||||
#[inline]
|
#[inline]
|
||||||
#[stable]
|
#[stable]
|
||||||
fn is<T: 'static>(self) -> bool {
|
fn is<T: 'static>(self) -> bool {
|
||||||
|
@ -181,7 +181,7 @@ pub trait AnyMutRefExt<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[stable]
|
#[stable]
|
||||||
impl<'a> AnyMutRefExt<'a> for &'a mut Any+'a {
|
impl<'a> AnyMutRefExt<'a> for &'a mut Any {
|
||||||
#[inline]
|
#[inline]
|
||||||
#[unstable = "naming conventions around acquiring references may change"]
|
#[unstable = "naming conventions around acquiring references may change"]
|
||||||
fn downcast_mut<T: 'static>(self) -> Option<&'a mut T> {
|
fn downcast_mut<T: 'static>(self) -> Option<&'a mut T> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue