]> git.lizzy.rs Git - rust.git/commitdiff
remove `Any[Mut]RefExt` traits in favor of `impl Any`
authorJorge Aparicio <japaricious@gmail.com>
Thu, 1 Jan 2015 06:13:08 +0000 (01:13 -0500)
committerJorge Aparicio <japaricious@gmail.com>
Sun, 4 Jan 2015 04:01:33 +0000 (23:01 -0500)
src/liballoc/boxed.rs
src/libcore/any.rs
src/librustc_driver/lib.rs
src/libstd/failure.rs
src/libstd/thread.rs
src/libtest/lib.rs
src/test/compile-fail/kindck-inherited-copy-bound.rs
src/test/run-pass/object-one-type-two-traits.rs

index e836b08459bb8032a67e0b4033031b44c52ee2f6..ca010ac986ab005a75400d55e970f1f913b83843 100644 (file)
@@ -12,7 +12,7 @@
 
 #![stable]
 
-use core::any::{Any, AnyRefExt};
+use core::any::Any;
 use core::clone::Clone;
 use core::cmp::{PartialEq, PartialOrd, Eq, Ord, Ordering};
 use core::default::Default;
index 75feb4d88289e5faf1343176b6eb3c1f3b7327ee..33cb335d756451dfab847d2311ea7082bd71fb19 100644 (file)
@@ -35,7 +35,7 @@
 //!
 //! ```rust
 //! use std::fmt::Show;
-//! use std::any::{Any, AnyRefExt};
+//! use std::any::Any;
 //!
 //! // Logger function for any type that implements Show.
 //! fn log<T: Any+Show>(value: &T) {
@@ -102,24 +102,11 @@ fn get_type_id(&self) -> TypeId { TypeId::of::<T>() }
 // Implemented as three extension traits so that the methods can be generic.
 ///////////////////////////////////////////////////////////////////////////////
 
-/// Extension methods for a referenced `Any` trait object
-#[unstable = "this trait will not be necessary once DST lands, it will be a \
-              part of `impl Any`"]
-pub trait AnyRefExt<'a> {
+impl Any {
     /// Returns true if the boxed type is the same as `T`
     #[stable]
-    fn is<T: 'static>(self) -> bool;
-
-    /// Returns some reference to the boxed value if it is of type `T`, or
-    /// `None` if it isn't.
-    #[unstable = "naming conventions around acquiring references may change"]
-    fn downcast_ref<T: 'static>(self) -> Option<&'a T>;
-}
-
-#[stable]
-impl<'a> AnyRefExt<'a> for &'a Any {
     #[inline]
-    fn is<T: 'static>(self) -> bool {
+    pub fn is<T: 'static>(&self) -> bool {
         // Get TypeId of the type this function is instantiated with
         let t = TypeId::of::<T>();
 
@@ -130,8 +117,11 @@ fn is<T: 'static>(self) -> bool {
         t == boxed
     }
 
+    /// Returns some reference to the boxed value if it is of type `T`, or
+    /// `None` if it isn't.
+    #[unstable = "naming conventions around acquiring references may change"]
     #[inline]
-    fn downcast_ref<T: 'static>(self) -> Option<&'a T> {
+    pub fn downcast_ref<'a, T: 'static>(&'a self) -> Option<&'a T> {
         if self.is::<T>() {
             unsafe {
                 // Get the raw representation of the trait object
@@ -144,22 +134,12 @@ fn downcast_ref<T: 'static>(self) -> Option<&'a T> {
             None
         }
     }
-}
 
-/// Extension methods for a mutable referenced `Any` trait object
-#[unstable = "this trait will not be necessary once DST lands, it will be a \
-              part of `impl Any`"]
-pub trait AnyMutRefExt<'a> {
     /// Returns some mutable reference to the boxed value if it is of type `T`, or
     /// `None` if it isn't.
     #[unstable = "naming conventions around acquiring references may change"]
-    fn downcast_mut<T: 'static>(self) -> Option<&'a mut T>;
-}
-
-#[stable]
-impl<'a> AnyMutRefExt<'a> for &'a mut Any {
     #[inline]
-    fn downcast_mut<T: 'static>(self) -> Option<&'a mut T> {
+    pub fn downcast_mut<'a, T: 'static>(&'a mut self) -> Option<&'a mut T> {
         if self.is::<T>() {
             unsafe {
                 // Get the raw representation of the trait object
index 9a993de098ea427176b28289d478006dcae3839c..983188c7090000e65b330cd0232f60fa5647b828 100644 (file)
@@ -54,7 +54,6 @@
 use rustc::metadata;
 use rustc::DIAGNOSTICS;
 
-use std::any::AnyRefExt;
 use std::cmp::Ordering::Equal;
 use std::io;
 use std::iter::repeat;
index d3bcdbf1a53e792c84bcff22662555c2efa32622..e48137047b0a95a81265a3264f776124f9db76de 100644 (file)
@@ -12,7 +12,7 @@
 
 use prelude::v1::*;
 
-use any::{Any, AnyRefExt};
+use any::Any;
 use cell::RefCell;
 use io::IoResult;
 use rt::{backtrace, unwind};
index 3c87309dabcf3ceb06e91edc35f009df841eb00e..371cf8b3b5a2ab3db959f3699efd19dc8a5858be 100644 (file)
@@ -442,7 +442,7 @@ fn drop(&mut self) {
 mod test {
     use prelude::v1::*;
 
-    use any::{Any, AnyRefExt};
+    use any::Any;
     use sync::mpsc::{channel, Sender};
     use boxed::BoxAny;
     use result;
index b2d3611fc64fcb0d76614fc546d6cca05f0d4dcc..e8d6b6f1ff634d2e5f7f5941cc5688a795775579 100644 (file)
@@ -58,7 +58,7 @@
 use term::Terminal;
 use term::color::{Color, RED, YELLOW, GREEN, CYAN};
 
-use std::any::{Any, AnyRefExt};
+use std::any::Any;
 use std::cmp;
 use std::collections::BTreeMap;
 use std::f64;
index f5740992af48eadba48e8fd4b2103f5b0d684950..d66fd0d77d6a9b6a6ef645a64e1ca8b7cbcf351b 100644 (file)
@@ -11,7 +11,6 @@
 // Test that Copy bounds inherited by trait are checked.
 
 use std::any::Any;
-use std::any::AnyRefExt;
 
 trait Foo : Copy {
 }
index f8bc0929bfa807fc0481a5b4ffd61d2714ee687c..4964b3f67284428ee4bdcfa7f3d35eaa2c9bdd1f 100644 (file)
@@ -12,7 +12,6 @@
 // traits.
 
 use std::any::Any;
-use std::any::AnyRefExt;
 
 trait Wrap {
     fn get(&self) -> int;