Explorar o código

Make `Leak` an invaraint.

We make the `Leak` trait unsafe and consituting an invariant. Secondly,
we implement `Leak` for all `Copy` types.
ticki %!s(int64=8) %!d(string=hai) anos
pai
achega
7f6b779a5f
Modificáronse 1 ficheiros con 4 adicións e 7 borrados
  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 {}