@@ -1080,26 +1080,26 @@ impl<T> Weak<T> {
1080
1080
/// ```
1081
1081
/// #![feature(weak_into_raw)]
1082
1082
///
1083
- /// use std::sync::{ Arc, Weak} ;
1083
+ /// use std::sync::Arc;
1084
1084
/// use std::ptr;
1085
1085
///
1086
1086
/// let strong = Arc::new("hello".to_owned());
1087
1087
/// let weak = Arc::downgrade(&strong);
1088
1088
/// // Both point to the same object
1089
- /// assert!(ptr::eq(&*strong, Weak:: as_raw(&weak )));
1089
+ /// assert!(ptr::eq(&*strong, weak. as_raw()));
1090
1090
/// // The strong here keeps it alive, so we can still access the object.
1091
- /// assert_eq!("hello", unsafe { &*Weak:: as_raw(&weak ) });
1091
+ /// assert_eq!("hello", unsafe { &*weak. as_raw() });
1092
1092
///
1093
1093
/// drop(strong);
1094
- /// // But not any more. We can do Weak:: as_raw(&weak ), but accessing the pointer would lead to
1094
+ /// // But not any more. We can do weak. as_raw(), but accessing the pointer would lead to
1095
1095
/// // undefined behaviour.
1096
- /// // assert_eq!("hello", unsafe { &*Weak:: as_raw(&weak ) });
1096
+ /// // assert_eq!("hello", unsafe { &*weak. as_raw() });
1097
1097
/// ```
1098
1098
///
1099
1099
/// [`null`]: ../../std/ptr/fn.null.html
1100
1100
#[ unstable( feature = "weak_into_raw" , issue = "60728" ) ]
1101
- pub fn as_raw ( this : & Self ) -> * const T {
1102
- match this . inner ( ) {
1101
+ pub fn as_raw ( & self ) -> * const T {
1102
+ match self . inner ( ) {
1103
1103
None => ptr:: null ( ) ,
1104
1104
Some ( inner) => {
1105
1105
let offset = data_offset_sized :: < T > ( ) ;
@@ -1130,7 +1130,7 @@ impl<T> Weak<T> {
1130
1130
///
1131
1131
/// let strong = Arc::new("hello".to_owned());
1132
1132
/// let weak = Arc::downgrade(&strong);
1133
- /// let raw = Weak:: into_raw(weak );
1133
+ /// let raw = weak. into_raw();
1134
1134
///
1135
1135
/// assert_eq!(1, Arc::weak_count(&strong));
1136
1136
/// assert_eq!("hello", unsafe { &*raw });
@@ -1142,9 +1142,9 @@ impl<T> Weak<T> {
1142
1142
/// [`from_raw`]: struct.Weak.html#method.from_raw
1143
1143
/// [`as_raw`]: struct.Weak.html#method.as_raw
1144
1144
#[ unstable( feature = "weak_into_raw" , issue = "60728" ) ]
1145
- pub fn into_raw ( this : Self ) -> * const T {
1146
- let result = Self :: as_raw ( & this ) ;
1147
- mem:: forget ( this ) ;
1145
+ pub fn into_raw ( self ) -> * const T {
1146
+ let result = self . as_raw ( ) ;
1147
+ mem:: forget ( self ) ;
1148
1148
result
1149
1149
}
1150
1150
@@ -1172,18 +1172,18 @@ impl<T> Weak<T> {
1172
1172
///
1173
1173
/// let strong = Arc::new("hello".to_owned());
1174
1174
///
1175
- /// let raw_1 = Weak::into_raw( Arc::downgrade(&strong));
1176
- /// let raw_2 = Weak::into_raw( Arc::downgrade(&strong));
1175
+ /// let raw_1 = Arc::downgrade(&strong).into_raw( );
1176
+ /// let raw_2 = Arc::downgrade(&strong).into_raw( );
1177
1177
///
1178
1178
/// assert_eq!(2, Arc::weak_count(&strong));
1179
1179
///
1180
- /// assert_eq!("hello", &*Weak::upgrade(& unsafe { Weak::from_raw(raw_1) }).unwrap());
1180
+ /// assert_eq!("hello", &*unsafe { Weak::from_raw(raw_1) }.upgrade( ).unwrap());
1181
1181
/// assert_eq!(1, Arc::weak_count(&strong));
1182
1182
///
1183
1183
/// drop(strong);
1184
1184
///
1185
1185
/// // Decrement the last weak count.
1186
- /// assert!(Weak::upgrade(& unsafe { Weak::from_raw(raw_2) }).is_none());
1186
+ /// assert!(unsafe { Weak::from_raw(raw_2) }.upgrade( ).is_none());
1187
1187
/// ```
1188
1188
///
1189
1189
/// [`null`]: ../../std/ptr/fn.null.html
0 commit comments