test the Rc::{into,from}_raw roundtrip
This uses some pointer arithmetic based on field offsets
This commit is contained in:
parent
03577a905a
commit
4b1a12c240
@ -8,6 +8,16 @@ fn rc_refcell() -> i32 {
|
||||
x
|
||||
}
|
||||
|
||||
fn rc_raw() {
|
||||
let r = Rc::new(0);
|
||||
let r2 = Rc::into_raw(r.clone());
|
||||
let r2 = unsafe { Rc::from_raw(r2) };
|
||||
assert!(Rc::ptr_eq(&r, &r2));
|
||||
drop(r);
|
||||
assert!(Rc::try_unwrap(r2).is_ok());
|
||||
}
|
||||
|
||||
fn main() {
|
||||
rc_refcell();
|
||||
rc_raw();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user