]> git.lizzy.rs Git - rust.git/commitdiff
Bound Any with 'static
authorJonathan Reem <jonathan.reem@gmail.com>
Tue, 9 Sep 2014 04:05:32 +0000 (21:05 -0700)
committerJonathan Reem <jonathan.reem@gmail.com>
Wed, 1 Oct 2014 01:40:07 +0000 (18:40 -0700)
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.

src/libcore/any.rs

index fb70cb5b752395d5d1bf01191cac056accf76b92..fd5007ff415f0869186b58c57a742ac0d9114433 100644 (file)
@@ -91,7 +91,7 @@ pub enum Void { }
 /// Every type with no non-`'static` references implements `Any`, so `Any` can
 /// be used as a trait object to emulate the effects dynamic typing.
 #[stable]
-pub trait Any: AnyPrivate {}
+pub trait Any: AnyPrivate + 'static {}
 
 /// An inner trait to ensure that only this module can call `get_type_id()`.
 pub trait AnyPrivate {
@@ -132,7 +132,7 @@ fn as_ref<T: 'static>(self) -> Option<&'a T> {
 }
 
 #[stable]
-impl<'a> AnyRefExt<'a> for &'a Any+'a {
+impl<'a> AnyRefExt<'a> for &'a Any {
     #[inline]
     #[stable]
     fn is<T: 'static>(self) -> bool {
@@ -181,7 +181,7 @@ fn as_mut<T: 'static>(self) -> Option<&'a mut T> {
 }
 
 #[stable]
-impl<'a> AnyMutRefExt<'a> for &'a mut Any+'a {
+impl<'a> AnyMutRefExt<'a> for &'a mut Any {
     #[inline]
     #[unstable = "naming conventions around acquiring references may change"]
     fn downcast_mut<T: 'static>(self) -> Option<&'a mut T> {