[−][src]Trait idalloc::Id
A type that can be used an allocator index.
Required methods
fn initial() -> Self
Allocate the initial, unallocated value.
Examples
use idalloc::Id as _; assert_eq!(0, u16::initial()); assert_eq!(0, u16::initial());
fn as_usize(self) -> usize
Get the index as a usize.
Examples
use idalloc::Id as _; assert_eq!(42, 42u16.as_usize()); assert_eq!(42, 42u32.as_usize());
fn increment(self) -> Self
Increment the index and return the incremented value.
Examples
use idalloc::Id as _; assert_eq!(1, 0u16.increment()); assert_eq!(1, 0u32.increment());
fn take(&mut self) -> Self
Take the value and replace the existing value with the none variant.
Examples
use idalloc::Id as _; let mut v = 1u32; assert_eq!(1u32, v.take()); assert_eq!(u32::none(), v);
fn expect(self, m: &str) -> Self
Test if the current value is none, and panic with the given message if if is.
Examples
use idalloc::Id as _; let mut v = 1u32; assert_eq!(1u32, v.expect("value must be defined"));
fn none() -> Self
Construct the none sentinel value for this type.
Examples
use idalloc::Id as _; assert!(u32::none().is_none());
fn is_none(self) -> bool
Test if the value is the none sentinel value.
Examples
use idalloc::Id as _; assert!(u32::none().is_none());