@@ -1080,26 +1080,26 @@ impl<T> Weak<T> {
10801080 /// ```
10811081 /// #![feature(weak_into_raw)]
10821082 ///
1083- /// use std::sync::{ Arc, Weak} ;
1083+ /// use std::sync::Arc;
10841084 /// use std::ptr;
10851085 ///
10861086 /// let strong = Arc::new("hello".to_owned());
10871087 /// let weak = Arc::downgrade(&strong);
10881088 /// // Both point to the same object
1089- /// assert!(ptr::eq(&*strong, Weak:: as_raw(&weak )));
1089+ /// assert!(ptr::eq(&*strong, weak. as_raw()));
10901090 /// // 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() });
10921092 ///
10931093 /// 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
10951095 /// // undefined behaviour.
1096- /// // assert_eq!("hello", unsafe { &*Weak:: as_raw(&weak ) });
1096+ /// // assert_eq!("hello", unsafe { &*weak. as_raw() });
10971097 /// ```
10981098 ///
10991099 /// [`null`]: ../../std/ptr/fn.null.html
11001100 #[ 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 ( ) {
11031103 None => ptr:: null ( ) ,
11041104 Some ( inner) => {
11051105 let offset = data_offset_sized :: < T > ( ) ;
@@ -1130,7 +1130,7 @@ impl<T> Weak<T> {
11301130 ///
11311131 /// let strong = Arc::new("hello".to_owned());
11321132 /// let weak = Arc::downgrade(&strong);
1133- /// let raw = Weak:: into_raw(weak );
1133+ /// let raw = weak. into_raw();
11341134 ///
11351135 /// assert_eq!(1, Arc::weak_count(&strong));
11361136 /// assert_eq!("hello", unsafe { &*raw });
@@ -1142,9 +1142,9 @@ impl<T> Weak<T> {
11421142 /// [`from_raw`]: struct.Weak.html#method.from_raw
11431143 /// [`as_raw`]: struct.Weak.html#method.as_raw
11441144 #[ 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 ) ;
11481148 result
11491149 }
11501150
@@ -1172,18 +1172,18 @@ impl<T> Weak<T> {
11721172 ///
11731173 /// let strong = Arc::new("hello".to_owned());
11741174 ///
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( );
11771177 ///
11781178 /// assert_eq!(2, Arc::weak_count(&strong));
11791179 ///
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());
11811181 /// assert_eq!(1, Arc::weak_count(&strong));
11821182 ///
11831183 /// drop(strong);
11841184 ///
11851185 /// // 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());
11871187 /// ```
11881188 ///
11891189 /// [`null`]: ../../std/ptr/fn.null.html
0 commit comments