Skip to content

Commit e5af0e5

Browse files
committed
fixup! docs: Use String in Rc::into_raw examples
1 parent 764d163 commit e5af0e5

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/liballoc/rc.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -375,9 +375,9 @@ impl<T: ?Sized> Rc<T> {
375375
/// ```
376376
/// use std::rc::Rc;
377377
///
378-
/// let x = Rc::new(10);
378+
/// let x = Rc::new("hello".to_owned());
379379
/// let x_ptr = Rc::into_raw(x);
380-
/// assert_eq!(unsafe { *x_ptr }, 10);
380+
/// assert_eq!(unsafe { &*x_ptr }, "hello");
381381
/// ```
382382
#[stable(feature = "rc_raw", since = "1.17.0")]
383383
pub fn into_raw(this: Self) -> *const T {
@@ -401,13 +401,13 @@ impl<T: ?Sized> Rc<T> {
401401
/// ```
402402
/// use std::rc::Rc;
403403
///
404-
/// let x = Rc::new(10);
404+
/// let x = Rc::new("hello".to_owned());
405405
/// let x_ptr = Rc::into_raw(x);
406406
///
407407
/// unsafe {
408408
/// // Convert back to an `Rc` to prevent leak.
409409
/// let x = Rc::from_raw(x_ptr);
410-
/// assert_eq!(*x, 10);
410+
/// assert_eq!(&*x, "hello");
411411
///
412412
/// // Further calls to `Rc::from_raw(x_ptr)` would be memory unsafe.
413413
/// }
@@ -437,10 +437,10 @@ impl<T: ?Sized> Rc<T> {
437437
///
438438
/// use std::rc::Rc;
439439
///
440-
/// let x = Rc::new(10);
440+
/// let x = Rc::new("hello".to_owned());
441441
/// let ptr = Rc::into_raw_non_null(x);
442-
/// let deref = unsafe { *ptr.as_ref() };
443-
/// assert_eq!(deref, 10);
442+
/// let deref = unsafe { ptr.as_ref() };
443+
/// assert_eq!(deref, "hello");
444444
/// ```
445445
#[unstable(feature = "rc_into_raw_non_null", issue = "47336")]
446446
#[inline]

src/liballoc/sync.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -356,9 +356,9 @@ impl<T: ?Sized> Arc<T> {
356356
/// ```
357357
/// use std::sync::Arc;
358358
///
359-
/// let x = Arc::new(10);
359+
/// let x = Arc::new("hello".to_owned());
360360
/// let x_ptr = Arc::into_raw(x);
361-
/// assert_eq!(unsafe { *x_ptr }, 10);
361+
/// assert_eq!(unsafe { &*x_ptr }, "hello");
362362
/// ```
363363
#[stable(feature = "rc_raw", since = "1.17.0")]
364364
pub fn into_raw(this: Self) -> *const T {
@@ -382,13 +382,13 @@ impl<T: ?Sized> Arc<T> {
382382
/// ```
383383
/// use std::sync::Arc;
384384
///
385-
/// let x = Arc::new(10);
385+
/// let x = Arc::new("hello".to_owned());
386386
/// let x_ptr = Arc::into_raw(x);
387387
///
388388
/// unsafe {
389389
/// // Convert back to an `Arc` to prevent leak.
390390
/// let x = Arc::from_raw(x_ptr);
391-
/// assert_eq!(*x, 10);
391+
/// assert_eq!(&*x, "hello");
392392
///
393393
/// // Further calls to `Arc::from_raw(x_ptr)` would be memory unsafe.
394394
/// }
@@ -418,10 +418,10 @@ impl<T: ?Sized> Arc<T> {
418418
///
419419
/// use std::sync::Arc;
420420
///
421-
/// let x = Arc::new(10);
421+
/// let x = Arc::new("hello".to_owned());
422422
/// 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");
425425
/// ```
426426
#[unstable(feature = "rc_into_raw_non_null", issue = "47336")]
427427
#[inline]

0 commit comments

Comments
 (0)