pub struct Index<LevelMask: BitBlock, LevelCount: ConstInteger>(/* private fields */);
Expand description
Range checked index.
Known to be within HibitTree<LevelMaskType, LevelCount>::index_range()
.
Whenever you see impl Into<Index<_, _>>
- you can just use your usize
index
as usual.
Index range check is very cheap, and is just one assert_eq with constant value.
But in tight loops you may want to get rid of that check - and that’s the sole
purpose of Index
.
// use it just as usize
array.get(12);
// zero-cost unsafe construction
array.get(unsafe{ Index::new_unchecked(12) });
// safe construct once, then reuse
{
let i = Index::from(12);
array.get(i);
array2.get(i);
}
Implementations§
Source§impl<LevelMaskType: BitBlock, LevelCount: ConstInteger> Index<LevelMaskType, LevelCount>
impl<LevelMaskType: BitBlock, LevelCount: ConstInteger> Index<LevelMaskType, LevelCount>
Sourcepub unsafe fn new_unchecked(index: usize) -> Self
pub unsafe fn new_unchecked(index: usize) -> Self
§Safety
You must guarantee that index is in SparseHierarchy<LevelMaskType, LevelCount> range.
Trait Implementations§
Source§impl<LevelMaskType: BitBlock, LevelCount: ConstInteger> From<Index<LevelMaskType, LevelCount>> for usize
SparseHierarchyIndex -> usize
impl<LevelMaskType: BitBlock, LevelCount: ConstInteger> From<Index<LevelMaskType, LevelCount>> for usize
SparseHierarchyIndex -> usize
Source§impl<LevelMaskType: BitBlock, LevelCount: ConstInteger> From<usize> for Index<LevelMaskType, LevelCount>
usize -> SparseHierarchyIndex
impl<LevelMaskType: BitBlock, LevelCount: ConstInteger> From<usize> for Index<LevelMaskType, LevelCount>
usize -> SparseHierarchyIndex
impl<LevelMask: BitBlock, LevelCount: ConstInteger> Copy for Index<LevelMask, LevelCount>
Auto Trait Implementations§
impl<LevelMask, LevelCount> Freeze for Index<LevelMask, LevelCount>
impl<LevelMask, LevelCount> RefUnwindSafe for Index<LevelMask, LevelCount>where
LevelMask: RefUnwindSafe,
LevelCount: RefUnwindSafe,
impl<LevelMask, LevelCount> Send for Index<LevelMask, LevelCount>
impl<LevelMask, LevelCount> Sync for Index<LevelMask, LevelCount>
impl<LevelMask, LevelCount> Unpin for Index<LevelMask, LevelCount>
impl<LevelMask, LevelCount> UnwindSafe for Index<LevelMask, LevelCount>where
LevelMask: UnwindSafe,
LevelCount: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more