Added tests for assume_init

This commit is contained in:
Albin Hedman 2020-12-02 19:14:10 +01:00
parent 1ef5dbe716
commit f311db100b

View File

@ -129,3 +129,21 @@ fn test_discriminant_send_sync() {
is_send_sync::<Discriminant<Regular>>();
is_send_sync::<Discriminant<NotSendSync>>();
}
#[test]
fn assume_init_good() {
const TRUE: bool = {
let mut x = MaybeUninit::<bool>::uninit();
x.as_mut_ptr().write(true);
x.assume_init()
};
assert!(TRUE);
}
#[test]
#[should_panic]
fn assume_init_bad() {
const BAD: () = {
MaybeUninit::<!>::uninit().assume_init();
};
}