Skip to content

Commit 8b18e78

Browse files
replace println! statements with assert!ions in std::ptr examples
r? @steveklabnik
1 parent 7ac11ca commit 8b18e78

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/libcore/ptr.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ pub unsafe fn replace<T>(dest: *mut T, mut src: T) -> T {
128128
/// let x = 12;
129129
/// let y = &x as *const i32;
130130
///
131-
/// unsafe { println!("{}", std::ptr::read(y)); }
131+
/// unsafe {
132+
/// assert_eq!(std::ptr::read(y), 12);
133+
/// }
132134
/// ```
133135
#[inline(always)]
134136
#[stable(feature = "rust1", since = "1.0.0")]
@@ -178,7 +180,7 @@ pub unsafe fn read_and_drop<T>(dest: *mut T) -> T {
178180
///
179181
/// unsafe {
180182
/// std::ptr::write(y, z);
181-
/// println!("{}", std::ptr::read(y));
183+
/// assert_eq!(std::ptr::read(y), 12);
182184
/// }
183185
/// ```
184186
#[inline]
@@ -220,7 +222,9 @@ pub unsafe fn write<T>(dst: *mut T, src: T) {
220222
/// let x = 12;
221223
/// let y = &x as *const i32;
222224
///
223-
/// unsafe { println!("{}", std::ptr::read_volatile(y)); }
225+
/// unsafe {
226+
/// assert_eq!(std::ptr::read_volatile(y), 12);
227+
/// }
224228
/// ```
225229
#[inline]
226230
#[stable(feature = "volatile", since = "1.9.0")]
@@ -266,7 +270,7 @@ pub unsafe fn read_volatile<T>(src: *const T) -> T {
266270
///
267271
/// unsafe {
268272
/// std::ptr::write_volatile(y, z);
269-
/// println!("{}", std::ptr::read_volatile(y));
273+
/// assert_eq!(std::ptr::read_volatile(y), 12);
270274
/// }
271275
/// ```
272276
#[inline]

0 commit comments

Comments
 (0)