Rewrite Unique<T> so that it is covariant in T, implies NonZero and ownership,

and also follows the API of `NonZero` a bit more closely. More to do
here I think (including perhaps a new name).
This commit is contained in:
Niko Matsakis
2015-02-12 10:33:21 -05:00
parent 8c841f2a31
commit 801bc48939
3 changed files with 38 additions and 27 deletions

View File

@@ -171,8 +171,8 @@ fn test_set_memory() {
#[test]
fn test_unsized_unique() {
let xs: &mut [_] = &mut [1, 2, 3];
let ptr = Unique(xs as *mut [_]);
let ys = unsafe { &mut *ptr.ptr };
let ptr = unsafe { Unique::new(xs as *mut [_]) };
let ys = unsafe { &mut **ptr };
let zs: &mut [_] = &mut [1, 2, 3];
assert!(ys == zs);
}