Trait read_fonts::collections::int_set::Domain
source · pub trait Domain: Sized {
// Required methods
fn to_u32(&self) -> u32;
fn from_u32(member: InDomain) -> Self;
fn is_continuous() -> bool;
fn ordered_values() -> impl DoubleEndedIterator<Item = u32>;
fn ordered_values_range(
range: RangeInclusive<Self>,
) -> impl DoubleEndedIterator<Item = u32>;
fn count() -> u64;
}
Expand description
Defines the domain of IntSet
member types.
Members of IntSet
must implement this trait. Members of IntSet
’s must meet the following
conditions to be used in an IntSet
:
-
Every possible unique value of
T
must be able map to and from a uniqueu32
integer. -
The mapped
u32
values must retain the same ordering as the values inT
. -
ordered_values
() must iterate over all values inT
in sorted order (ascending).
from_u32
() will only ever be called with u32 values that are part of the domain of T as defined
by an implementation of this trait. So it doesn’t need to correctly handle values
that are outside the domain of T
.
Required Methods§
sourcefn to_u32(&self) -> u32
fn to_u32(&self) -> u32
Converts this value of T
to a value in u32.
The mapped value must maintain the same ordering as T
.
sourcefn from_u32(member: InDomain) -> Self
fn from_u32(member: InDomain) -> Self
Converts a mapped u32 value back to T.
Will only ever be called with values produced by to_u32
.
sourcefn is_continuous() -> bool
fn is_continuous() -> bool
Returns true if all u32 values between the mapped u32 min and mapped u32 max value of T are used.
sourcefn ordered_values() -> impl DoubleEndedIterator<Item = u32>
fn ordered_values() -> impl DoubleEndedIterator<Item = u32>
Returns an iterator which iterates over all values in the domain of T
Values should be converted to u32
’s according to the mapping defined in
to_u32
/from_u32
.
sourcefn ordered_values_range(
range: RangeInclusive<Self>,
) -> impl DoubleEndedIterator<Item = u32>
fn ordered_values_range( range: RangeInclusive<Self>, ) -> impl DoubleEndedIterator<Item = u32>
Return an iterator which iterates over all values of T in the given range.
Values should be converted to u32
’s according to the mapping defined in
to_u32
/from_u32
.