Skip to content

Commit 73772fe

Browse files
committed
adjust for Weak::as_raw -> as_ptr rename
1 parent 5d2c835 commit 73772fe

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

tests/compile-fail/rc_as_raw.rs renamed to tests/compile-fail/rc_as_ptr.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55
use std::rc::{Rc, Weak};
66
use std::ptr;
77

8-
/// Taken from the `Weak::as_raw` doctest.
8+
/// Taken from the `Weak::as_ptr` doctest.
99
fn main() {
1010
let strong = Rc::new(Box::new(42));
1111
let weak = Rc::downgrade(&strong);
1212
// Both point to the same object
13-
assert!(ptr::eq(&*strong, Weak::as_raw(&weak)));
13+
assert!(ptr::eq(&*strong, Weak::as_ptr(&weak)));
1414
// The strong here keeps it alive, so we can still access the object.
15-
assert_eq!(42, **unsafe { &*Weak::as_raw(&weak) });
15+
assert_eq!(42, **unsafe { &*Weak::as_ptr(&weak) });
1616

1717
drop(strong);
1818
// But not any more. We can do Weak::as_raw(&weak), but accessing the pointer would lead to
1919
// undefined behaviour.
20-
assert_eq!(42, **unsafe { &*Weak::as_raw(&weak) }); //~ ERROR dereferenced after this allocation got freed
20+
assert_eq!(42, **unsafe { &*Weak::as_ptr(&weak) }); //~ ERROR dereferenced after this allocation got freed
2121
}

0 commit comments

Comments
 (0)