pub struct DateRange {
pub start: MaterialDate,
pub end: Option<MaterialDate>,
}Expand description
A selected date range: a start, and an end that is None while the user
is mid-selection — the reference’s M3EDateRange.
§Scope: the model ships, the range dialog does not
The reference ships a full range picker
(M3EDateRangePickerDialog/M3ECalendarDateRangePicker), presented as a
vertically scrolling list of every month between firstDate and
lastDate. This port carries the range model (this type, plus
Self::extend’s selection rule) and the day cell’s range visuals
(crate::CalendarDatePicker::range), so an app can drive range selection
against the single-month calendar; the scrolling multi-month dialog itself
is a deliberate v1 cut, for the same reason [crate::dialog]’s selection
list has no scroll physics — see crate::date_picker’s scope section.
Fields§
§start: MaterialDateThe first day of the range.
end: Option<MaterialDate>The last day of the range, or None while only a start has been picked.
Implementations§
Source§impl DateRange
impl DateRange
Sourcepub fn new(start: MaterialDate) -> Self
pub fn new(start: MaterialDate) -> Self
A range with only its start picked.
Sourcepub fn closed(start: MaterialDate, end: MaterialDate) -> Self
pub fn closed(start: MaterialDate, end: MaterialDate) -> Self
A closed start..=end range. A reversed pair is swapped rather than
stored inverted, so Self::contains can never be vacuously false.
Sourcepub fn is_complete(self) -> bool
pub fn is_complete(self) -> bool
Whether both ends are picked — the reference’s M3EDateRange.isComplete.
Sourcepub fn contains(self, day: MaterialDate) -> bool
pub fn contains(self, day: MaterialDate) -> bool
Whether day lies inside the range, inclusive of both ends. An
unfinished range contains only its own start.
Sourcepub fn extend(current: Option<Self>, date: MaterialDate) -> Self
pub fn extend(current: Option<Self>, date: MaterialDate) -> Self
The range a tap on date produces, given current — the reference’s
_M3ECalendarDateRangePickerState._updateSelection: a tap closes an
open range when it lands on or after its start, and otherwise restarts
a fresh open range at the tapped day.
use frust_material::{DateRange, MaterialDate};
let d = |day| MaterialDate::new(2026, 8, day);
let opened = DateRange::extend(None, d(3));
assert_eq!(opened, DateRange::new(d(3)));
// A later day closes it...
assert_eq!(DateRange::extend(Some(opened), d(9)).end, Some(d(9)));
// ...an earlier one restarts it.
assert_eq!(DateRange::extend(Some(opened), d(1)), DateRange::new(d(1)));
// A tap on a *closed* range always restarts.
let closed = DateRange::closed(d(3), d(9));
assert_eq!(DateRange::extend(Some(closed), d(5)), DateRange::new(d(5)));Trait Implementations§
impl Copy for DateRange
impl Eq for DateRange
impl StructuralPartialEq for DateRange
Auto Trait Implementations§
impl Freeze for DateRange
impl RefUnwindSafe for DateRange
impl Send for DateRange
impl Sync for DateRange
impl Unpin for DateRange
impl UnsafeUnpin for DateRange
impl UnwindSafe for DateRange
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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.