@@ -81,28 +81,24 @@ pub trait Any: 'static {
81
81
/// # Examples
82
82
///
83
83
/// ```
84
- /// #![feature(get_type_id)]
85
- ///
86
84
/// use std::any::{Any, TypeId};
87
85
///
88
86
/// fn is_string(s: &dyn Any) -> bool {
89
- /// TypeId::of::<String>() == s.get_type_id ()
87
+ /// TypeId::of::<String>() == s.type_id ()
90
88
/// }
91
89
///
92
90
/// fn main() {
93
91
/// assert_eq!(is_string(&0), false);
94
92
/// assert_eq!(is_string(&"cookie monster".to_string()), true);
95
93
/// }
96
94
/// ```
97
- #[ unstable( feature = "get_type_id" ,
98
- reason = "this method will likely be replaced by an associated static" ,
99
- issue = "27745" ) ]
100
- fn get_type_id ( & self ) -> TypeId ;
95
+ #[ stable( feature = "get_type_id" , since = "1.34.0" ) ]
96
+ fn type_id ( & self ) -> TypeId ;
101
97
}
102
98
103
99
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
104
100
impl < T : ' static + ?Sized > Any for T {
105
- fn get_type_id ( & self ) -> TypeId { TypeId :: of :: < T > ( ) }
101
+ fn type_id ( & self ) -> TypeId { TypeId :: of :: < T > ( ) }
106
102
}
107
103
108
104
///////////////////////////////////////////////////////////////////////////////
@@ -161,10 +157,10 @@ impl dyn Any {
161
157
let t = TypeId :: of :: < T > ( ) ;
162
158
163
159
// Get TypeId of the type in the trait object
164
- let boxed = self . get_type_id ( ) ;
160
+ let concrete = self . type_id ( ) ;
165
161
166
162
// Compare both TypeIds on equality
167
- t == boxed
163
+ t == concrete
168
164
}
169
165
170
166
/// Returns some reference to the boxed value if it is of type `T`, or
0 commit comments