pub struct Schedule { /* private fields */ }Expand description
Describe a full schedule for a day, keeping track of open, closed and unknown periods.
It can be turned into an iterator which will yield consecutive ranges of different states, with no holes or overlapping.
Implementations§
Source§impl Schedule
impl Schedule
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new empty schedule, which represents an always closed period.
use opening_hours::schedule::Schedule;
assert!(Schedule::new().is_empty());Sourcepub fn from_ranges(
ranges: impl IntoIterator<Item = Range<ExtendedTime>>,
kind: RuleKind,
comments: &UniqueSortedVec<Arc<str>>,
) -> Self
pub fn from_ranges( ranges: impl IntoIterator<Item = Range<ExtendedTime>>, kind: RuleKind, comments: &UniqueSortedVec<Arc<str>>, ) -> Self
Create a new schedule from a list of ranges of same kind and comment.
use opening_hours::schedule::Schedule;
use opening_hours_syntax::{ExtendedTime, RuleKind};
let sch1 = Schedule::from_ranges(
[
ExtendedTime::new(10, 0).unwrap()..ExtendedTime::new(14, 0).unwrap(),
ExtendedTime::new(12, 0).unwrap()..ExtendedTime::new(16, 0).unwrap(),
],
RuleKind::Open,
&Default::default(),
);
let sch2 = Schedule::from_ranges(
[ExtendedTime::new(10, 0).unwrap()..ExtendedTime::new(16, 0).unwrap()],
RuleKind::Open,
&Default::default(),
);
assert_eq!(sch1, sch2);Trait Implementations§
Source§impl IntoIterator for Schedule
impl IntoIterator for Schedule
impl Eq for Schedule
impl StructuralPartialEq for Schedule
Auto Trait Implementations§
impl Freeze for Schedule
impl RefUnwindSafe for Schedule
impl Send for Schedule
impl Sync for Schedule
impl Unpin for Schedule
impl UnsafeUnpin for Schedule
impl UnwindSafe for Schedule
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