@@ -356,9 +356,9 @@ impl<T: ?Sized> Arc<T> {
356
356
/// ```
357
357
/// use std::sync::Arc;
358
358
///
359
- /// let x = Arc::new(10 );
359
+ /// let x = Arc::new("hello".to_owned() );
360
360
/// let x_ptr = Arc::into_raw(x);
361
- /// assert_eq!(unsafe { *x_ptr }, 10 );
361
+ /// assert_eq!(unsafe { & *x_ptr }, "hello" );
362
362
/// ```
363
363
#[ stable( feature = "rc_raw" , since = "1.17.0" ) ]
364
364
pub fn into_raw ( this : Self ) -> * const T {
@@ -382,13 +382,13 @@ impl<T: ?Sized> Arc<T> {
382
382
/// ```
383
383
/// use std::sync::Arc;
384
384
///
385
- /// let x = Arc::new(10 );
385
+ /// let x = Arc::new("hello".to_owned() );
386
386
/// let x_ptr = Arc::into_raw(x);
387
387
///
388
388
/// unsafe {
389
389
/// // Convert back to an `Arc` to prevent leak.
390
390
/// let x = Arc::from_raw(x_ptr);
391
- /// assert_eq!(*x, 10 );
391
+ /// assert_eq!(& *x, "hello" );
392
392
///
393
393
/// // Further calls to `Arc::from_raw(x_ptr)` would be memory unsafe.
394
394
/// }
@@ -418,10 +418,10 @@ impl<T: ?Sized> Arc<T> {
418
418
///
419
419
/// use std::sync::Arc;
420
420
///
421
- /// let x = Arc::new(10 );
421
+ /// let x = Arc::new("hello".to_owned() );
422
422
/// let ptr = Arc::into_raw_non_null(x);
423
- /// let deref = unsafe { * ptr.as_ref() };
424
- /// assert_eq!(deref, 10 );
423
+ /// let deref = unsafe { ptr.as_ref() };
424
+ /// assert_eq!(deref, "hello" );
425
425
/// ```
426
426
#[ unstable( feature = "rc_into_raw_non_null" , issue = "47336" ) ]
427
427
#[ inline]
@@ -1083,17 +1083,17 @@ impl<T> Weak<T> {
1083
1083
/// use std::sync::{Arc, Weak};
1084
1084
/// use std::ptr;
1085
1085
///
1086
- /// let strong = Arc::new(42 );
1086
+ /// let strong = Arc::new("hello".to_owned() );
1087
1087
/// let weak = Arc::downgrade(&strong);
1088
1088
/// // Both point to the same object
1089
1089
/// assert!(ptr::eq(&*strong, Weak::as_raw(&weak)));
1090
1090
/// // The strong here keeps it alive, so we can still access the object.
1091
- /// assert_eq!(42 , unsafe { *Weak::as_raw(&weak) });
1091
+ /// assert_eq!("hello" , unsafe { & *Weak::as_raw(&weak) });
1092
1092
///
1093
1093
/// drop(strong);
1094
1094
/// // But not any more. We can do Weak::as_raw(&weak), but accessing the pointer would lead to
1095
1095
/// // undefined behaviour.
1096
- /// // assert_eq!(42 , unsafe { *Weak::as_raw(&weak) });
1096
+ /// // assert_eq!("hello" , unsafe { & *Weak::as_raw(&weak) });
1097
1097
/// ```
1098
1098
///
1099
1099
/// [`null`]: ../../std/ptr/fn.null.html
@@ -1128,12 +1128,12 @@ impl<T> Weak<T> {
1128
1128
///
1129
1129
/// use std::sync::{Arc, Weak};
1130
1130
///
1131
- /// let strong = Arc::new(42 );
1131
+ /// let strong = Arc::new("hello".to_owned() );
1132
1132
/// let weak = Arc::downgrade(&strong);
1133
1133
/// let raw = Weak::into_raw(weak);
1134
1134
///
1135
1135
/// assert_eq!(1, Arc::weak_count(&strong));
1136
- /// assert_eq!(42 , unsafe { *raw });
1136
+ /// assert_eq!("hello" , unsafe { & *raw });
1137
1137
///
1138
1138
/// drop(unsafe { Weak::from_raw(raw) });
1139
1139
/// assert_eq!(0, Arc::weak_count(&strong));
@@ -1170,14 +1170,14 @@ impl<T> Weak<T> {
1170
1170
///
1171
1171
/// use std::sync::{Arc, Weak};
1172
1172
///
1173
- /// let strong = Arc::new(42 );
1173
+ /// let strong = Arc::new("hello".to_owned() );
1174
1174
///
1175
1175
/// let raw_1 = Weak::into_raw(Arc::downgrade(&strong));
1176
1176
/// let raw_2 = Weak::into_raw(Arc::downgrade(&strong));
1177
1177
///
1178
1178
/// assert_eq!(2, Arc::weak_count(&strong));
1179
1179
///
1180
- /// assert_eq!(42, *Weak::upgrade(&unsafe { Weak::from_raw(raw_1) }).unwrap());
1180
+ /// assert_eq!("hello", & *Weak::upgrade(&unsafe { Weak::from_raw(raw_1) }).unwrap());
1181
1181
/// assert_eq!(1, Arc::weak_count(&strong));
1182
1182
///
1183
1183
/// drop(strong);
0 commit comments