]>
git.proxmox.com Git - rustc.git/blob - vendor/maybe-uninit/tests/doesnt_drop.rs
1 extern crate maybe_uninit
;
2 use maybe_uninit
::MaybeUninit
;
6 struct DecrementOnDrop
<'a
>(&'a Cell
<usize>);
8 impl<'a
> DecrementOnDrop
<'a
> {
9 pub fn new(ref_
:&'a Cell
<usize>) -> Self {
15 impl<'a
> Clone
for DecrementOnDrop
<'a
> {
16 fn clone(&self) -> Self {
17 self.0.set(self.0.get() + 1);
19 DecrementOnDrop(self.0)
23 impl<'a
> Drop
for DecrementOnDrop
<'a
>{
25 self.0.set(self.0.get() - 1);
31 let count
= Cell
::new(0);
32 let arc
= DecrementOnDrop
::new(&count
);
33 let maybe
= MaybeUninit
::new(arc
.clone());
34 assert_eq
!(count
.get(), 2);
36 assert_eq
!(count
.get(), 2);