Skip to content

Commit

Permalink
fixup! docs: Use String in Rc::into_raw examples
Browse files Browse the repository at this point in the history
  • Loading branch information
vorner committed Jun 12, 2019
1 parent 764d163 commit e5af0e5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
14 changes: 7 additions & 7 deletions src/liballoc/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,9 @@ impl<T: ?Sized> Rc<T> {
/// ```
/// use std::rc::Rc;
///
/// let x = Rc::new(10);
/// let x = Rc::new("hello".to_owned());
/// let x_ptr = Rc::into_raw(x);
/// assert_eq!(unsafe { *x_ptr }, 10);
/// assert_eq!(unsafe { &*x_ptr }, "hello");
/// ```
#[stable(feature = "rc_raw", since = "1.17.0")]
pub fn into_raw(this: Self) -> *const T {
Expand All @@ -401,13 +401,13 @@ impl<T: ?Sized> Rc<T> {
/// ```
/// use std::rc::Rc;
///
/// let x = Rc::new(10);
/// let x = Rc::new("hello".to_owned());
/// let x_ptr = Rc::into_raw(x);
///
/// unsafe {
/// // Convert back to an `Rc` to prevent leak.
/// let x = Rc::from_raw(x_ptr);
/// assert_eq!(*x, 10);
/// assert_eq!(&*x, "hello");
///
/// // Further calls to `Rc::from_raw(x_ptr)` would be memory unsafe.
/// }
Expand Down Expand Up @@ -437,10 +437,10 @@ impl<T: ?Sized> Rc<T> {
///
/// use std::rc::Rc;
///
/// let x = Rc::new(10);
/// let x = Rc::new("hello".to_owned());
/// let ptr = Rc::into_raw_non_null(x);
/// let deref = unsafe { *ptr.as_ref() };
/// assert_eq!(deref, 10);
/// let deref = unsafe { ptr.as_ref() };
/// assert_eq!(deref, "hello");
/// ```
#[unstable(feature = "rc_into_raw_non_null", issue = "47336")]
#[inline]
Expand Down
14 changes: 7 additions & 7 deletions src/liballoc/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,9 @@ impl<T: ?Sized> Arc<T> {
/// ```
/// use std::sync::Arc;
///
/// let x = Arc::new(10);
/// let x = Arc::new("hello".to_owned());
/// let x_ptr = Arc::into_raw(x);
/// assert_eq!(unsafe { *x_ptr }, 10);
/// assert_eq!(unsafe { &*x_ptr }, "hello");
/// ```
#[stable(feature = "rc_raw", since = "1.17.0")]
pub fn into_raw(this: Self) -> *const T {
Expand All @@ -382,13 +382,13 @@ impl<T: ?Sized> Arc<T> {
/// ```
/// use std::sync::Arc;
///
/// let x = Arc::new(10);
/// let x = Arc::new("hello".to_owned());
/// let x_ptr = Arc::into_raw(x);
///
/// unsafe {
/// // Convert back to an `Arc` to prevent leak.
/// let x = Arc::from_raw(x_ptr);
/// assert_eq!(*x, 10);
/// assert_eq!(&*x, "hello");
///
/// // Further calls to `Arc::from_raw(x_ptr)` would be memory unsafe.
/// }
Expand Down Expand Up @@ -418,10 +418,10 @@ impl<T: ?Sized> Arc<T> {
///
/// use std::sync::Arc;
///
/// let x = Arc::new(10);
/// let x = Arc::new("hello".to_owned());
/// let ptr = Arc::into_raw_non_null(x);
/// let deref = unsafe { *ptr.as_ref() };
/// assert_eq!(deref, 10);
/// let deref = unsafe { ptr.as_ref() };
/// assert_eq!(deref, "hello");
/// ```
#[unstable(feature = "rc_into_raw_non_null", issue = "47336")]
#[inline]
Expand Down

0 comments on commit e5af0e5

Please sign in to comment.