Skip to content

replace println! statements with assert!ions in std::ptr examples #35878

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 23, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/libcore/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ pub unsafe fn replace<T>(dest: *mut T, mut src: T) -> T {
/// let x = 12;
/// let y = &x as *const i32;
///
/// unsafe { println!("{}", std::ptr::read(y)); }
/// unsafe {
/// assert_eq!(std::ptr::read(y), 12);
/// }
/// ```
#[inline(always)]
#[stable(feature = "rust1", since = "1.0.0")]
Expand Down Expand Up @@ -178,7 +180,7 @@ pub unsafe fn read_and_drop<T>(dest: *mut T) -> T {
///
/// unsafe {
/// std::ptr::write(y, z);
/// println!("{}", std::ptr::read(y));
/// assert_eq!(std::ptr::read(y), 12);
/// }
/// ```
#[inline]
Expand Down Expand Up @@ -220,7 +222,9 @@ pub unsafe fn write<T>(dst: *mut T, src: T) {
/// let x = 12;
/// let y = &x as *const i32;
///
/// unsafe { println!("{}", std::ptr::read_volatile(y)); }
/// unsafe {
/// assert_eq!(std::ptr::read_volatile(y), 12);
/// }
/// ```
#[inline]
#[stable(feature = "volatile", since = "1.9.0")]
Expand Down Expand Up @@ -266,7 +270,7 @@ pub unsafe fn read_volatile<T>(src: *const T) -> T {
///
/// unsafe {
/// std::ptr::write_volatile(y, z);
/// println!("{}", std::ptr::read_volatile(y));
/// assert_eq!(std::ptr::read_volatile(y), 12);
/// }
/// ```
#[inline]
Expand Down