Ver código fonte

Make `Leak` an invaraint.

We make the `Leak` trait unsafe and consituting an invariant. Secondly,
we implement `Leak` for all `Copy` types.
ticki 8 anos atrás
pai
commit
7f6b779a5f
1 arquivos alterados com 4 adições e 7 exclusões
  1. 4 7
      src/leak.rs

+ 4 - 7
src/leak.rs

@@ -7,13 +7,10 @@ use prelude::*;
 
 /// Types that have no destructor.
 ///
-/// This trait act as a simple static assertions catching dumb logic errors and memory leaks.
+/// This trait holds the invariant that our type carries no destructor.
 ///
 /// Since one cannot define mutually exclusive traits, we have this as a temporary hack.
-pub trait Leak {}
+pub unsafe trait Leak {}
 
-impl Leak for () {}
-impl Leak for Block {}
-impl Leak for u8 {}
-impl Leak for u16 {}
-impl Leak for i32 {}
+unsafe impl Leak for Block {}
+unsafe impl<T: Copy> Leak for T {}