Skip to content
This repository has been archived by the owner on Dec 9, 2018. It is now read-only.

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

Open
japaric opened this issue May 6, 2015 · 0 comments
Open

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

japaric opened this issue May 6, 2015 · 0 comments

Comments

@japaric
Copy link
Contributor

japaric commented May 6, 2015

// 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 }
}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant