pub struct ElementIdRange {
pub first: u8,
pub last: u8,
}Expand description
An utility structure for storing ranges of element’s ids. It provides way of converting between element id (with optional sub-id) and exposed id.
This structure is small and therefore can be copied.
Fields§
§first: u8§last: u8Implementations§
Source§impl ElementIdRange
impl ElementIdRange
pub const fn new(first: u8, last: u8) -> Self
Sourcepub const fn slots_count(self) -> u8
pub const fn slots_count(self) -> u8
Returns the number of slots in this range.
Sourcepub const fn sub_slots_count(self, exposed_count: u16) -> u8
pub const fn sub_slots_count(self, exposed_count: u16) -> u8
Returns the number of slots that requires a sub-id. These slots are
starting from the end of the range. For example, if this function
returns 1, this means that the last slot (.last), if used, will be
followed by a sub-id.
You must given the total number of exposed ids, because the presence of sub-id depends on how exposed ids can fit in the id range.
Sourcepub const fn full_slots_count(self, exposed_count: u16) -> u8
pub const fn full_slots_count(self, exposed_count: u16) -> u8
Returns the number of full slots that don’t require a sub-id. This
is the opposite of sub_slots_count, read its documentation.
Sourcepub fn from_exposed_id(
self,
exposed_count: u16,
exposed_id: u16,
) -> (u8, Option<u8>)
pub fn from_exposed_id( self, exposed_count: u16, exposed_id: u16, ) -> (u8, Option<u8>)
Get the element’s id and optional sub-id from the given exposed id and total count of exposed ids.
Trait Implementations§
Source§impl Clone for ElementIdRange
impl Clone for ElementIdRange
Source§fn clone(&self) -> ElementIdRange
fn clone(&self) -> ElementIdRange
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ElementIdRange
impl Debug for ElementIdRange
Source§impl PartialEq for ElementIdRange
impl PartialEq for ElementIdRange
impl Copy for ElementIdRange
impl Eq for ElementIdRange
impl StructuralPartialEq for ElementIdRange
Auto Trait Implementations§
impl Freeze for ElementIdRange
impl RefUnwindSafe for ElementIdRange
impl Send for ElementIdRange
impl Sync for ElementIdRange
impl Unpin for ElementIdRange
impl UnwindSafe for ElementIdRange
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.