Skip to content

Commit 4566058

Browse files
authoredJun 13, 2017
Merge pull request rust-lang#195 from RalfJung/test
Test the Rc::{into,from}_raw roundtrip
2 parents 03577a9 + 4b1a12c commit 4566058

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed
 

Diff for: ‎tests/run-pass/rc.rs

+10
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ fn rc_refcell() -> i32 {
88
x
99
}
1010

11+
fn rc_raw() {
12+
let r = Rc::new(0);
13+
let r2 = Rc::into_raw(r.clone());
14+
let r2 = unsafe { Rc::from_raw(r2) };
15+
assert!(Rc::ptr_eq(&r, &r2));
16+
drop(r);
17+
assert!(Rc::try_unwrap(r2).is_ok());
18+
}
19+
1120
fn main() {
1221
rc_refcell();
22+
rc_raw();
1323
}

0 commit comments

Comments
 (0)
Please sign in to comment.