japaric-archived / linalg.rs

[INACTIVE]
Apache License 2.0
29 stars 1 forks source link

Add a `U31` type and use it to store all dimensions #56

Open japaric opened 9 years ago

japaric commented 9 years ago
// The `u32` is guaranteed to have its 31th bit set to 0
struct U31(u32);
// or `struct U31(i32)` where the `i32` is always positive

impl U31 {
    // both operations are infallible
    fn i32(self) -> i32 { i32::from(self).extract() }
    fn u32(self) -> u32 { self.0 }
}