Struct WeekdaySet
pub struct WeekdaySet(/* private field */);
A collection of Weekdays stored as a single byte.
This type is Copy and provides efficient set-like and slice-like operations.
Many operations are const as well.
Implemented as a bitmask where bits 1-7 correspond to Monday-Sunday.
Implementations
impl WeekdaySet
const fn from_array<const C: usize>(days: [Weekday; C]) -> SelfCreate a
WeekdaySetfrom an array ofWeekdays.Example
# use WeekdaySet; use *; assert_eq!; assert_eq!; assert_eq!;const fn single(weekday: Weekday) -> SelfCreate a
WeekdaySetfrom a singleWeekday.const fn single_day(self) -> Option<Weekday>Returns
Some(day)if this collection contains exactly one day.Returns
Noneotherwise.Example
# use WeekdaySet; use *; assert_eq!; assert_eq!; assert_eq!; assert_eq!;fn insert(&mut self, day: Weekday) -> boolAdds a day to the collection.
Returns
trueif the day was new to the collection.Example
# use WeekdaySet; use *; let mut weekdays = single; assert!; assert!;fn remove(&mut self, day: Weekday) -> boolRemoves a day from the collection.
Returns
trueif the collection did contain the day.Example
# use WeekdaySet; use *; let mut weekdays = single; assert!; assert!;const fn is_subset(self, other: Self) -> boolReturns
trueifothercontains all days inself.Example
# use WeekdaySet; use *; assert!; assert!; assert!;const fn intersection(self, other: Self) -> SelfReturns days that are in both
selfandother.Example
# use WeekdaySet; use *; assert_eq!; assert_eq!; assert_eq!; assert_eq!;const fn union(self, other: Self) -> SelfReturns days that are in either
selforother.Example
# use WeekdaySet; use *; assert_eq!; assert_eq!; assert_eq!; assert_eq!;const fn symmetric_difference(self, other: Self) -> SelfReturns days that are in
selforotherbut not in both.Example
# use WeekdaySet; use *; assert_eq!; assert_eq!; assert_eq!; assert_eq!;const fn difference(self, other: Self) -> SelfReturns days that are in
selfbut not inother.Example
# use WeekdaySet; use *; assert_eq!; assert_eq!; assert_eq!;const fn first(self) -> Option<Weekday>Get the first day in the collection, starting from Monday.
Returns
Noneif the collection is empty.Example
# use WeekdaySet; use *; assert_eq!; assert_eq!; assert_eq!; assert_eq!;fn last(self) -> Option<Weekday>Get the last day in the collection, starting from Sunday.
Returns
Noneif the collection is empty.Example
# use WeekdaySet; use *; assert_eq!; assert_eq!; assert_eq!; assert_eq!;const fn iter(self, start: Weekday) -> WeekdaySetIterIterate over the
Weekdays in the collection starting from a given day.Wraps around from Sunday to Monday if necessary.
Example
# use WeekdaySet; use *; let weekdays = from_array; let mut iter = weekdays.iter; assert_eq!; assert_eq!; assert_eq!; assert_eq!;const fn contains(self, day: Weekday) -> boolReturns
trueif the collection contains the given day.Example
# use WeekdaySet; use *; assert!; assert!; assert!;const fn is_empty(self) -> boolReturns
trueif the collection is empty.Example
# use ; assert!; assert!;const fn len(self) -> u8Returns the number of days in the collection.
Example
# use WeekdaySet; use *; assert_eq!; assert_eq!; assert_eq!;const EMPTY: Self = _;An empty
WeekdaySet.const ALL: Self = _;A
WeekdaySetcontaining all sevenWeekdays.
Trait Implementations
impl Clone for WeekdaySet
fn clone(&self) -> WeekdaySet
impl Copy for WeekdaySet
impl Debug for WeekdaySet
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Default for WeekdaySet
fn default() -> WeekdaySet
impl Display for WeekdaySet
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Eq for WeekdaySet
impl FromIterator<Weekday> for WeekdaySet
fn from_iter<T: IntoIterator<Item = Weekday>>(iter: T) -> Self
impl Hash for WeekdaySet
fn hash<__H: Hasher>(&self, state: &mut __H)
impl Ord for WeekdaySet
fn cmp(&self, other: &WeekdaySet) -> Ordering
impl PartialEq for WeekdaySet
fn eq(&self, other: &WeekdaySet) -> bool
impl PartialOrd for WeekdaySet
fn partial_cmp(&self, other: &WeekdaySet) -> Option<Ordering>
impl StructuralPartialEq for WeekdaySet
Auto Trait Implementations
impl Freeze for WeekdaySet
impl RefUnwindSafe for WeekdaySet
impl Send for WeekdaySet
impl Sync for WeekdaySet
impl Unpin for WeekdaySet
impl UnsafeUnpin for WeekdaySet
impl UnwindSafe for WeekdaySet
Blanket Implementations
impl<T> Any for WeekdaySet
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for WeekdaySet
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for WeekdaySet
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for WeekdaySet
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for WeekdaySet
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for WeekdaySet
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T> ToString for WeekdaySet
where
T: Display + ?Sized,
fn to_string(&self) -> String
impl<T, U> Into<U> for WeekdaySet
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for WeekdaySet
where
U: Into<T>,
type Error = Infallible;fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto<U> for WeekdaySet
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>