mirror of
https://github.com/chronotope/chrono.git
synced 2025-10-02 15:26:12 +00:00
Rename WeekdaySet::iter_from() to iter()
This commit is contained in:
parent
4094865116
commit
64c65a9256
@ -206,14 +206,14 @@ impl WeekdaySet {
|
|||||||
/// # use chrono::WeekdaySet;
|
/// # use chrono::WeekdaySet;
|
||||||
/// use chrono::Weekday::*;
|
/// use chrono::Weekday::*;
|
||||||
/// let weekdays = WeekdaySet::from_array([Mon, Wed, Fri]);
|
/// let weekdays = WeekdaySet::from_array([Mon, Wed, Fri]);
|
||||||
/// let mut iter = weekdays.iter_from(Wed);
|
/// let mut iter = weekdays.iter(Wed);
|
||||||
/// assert_eq!(iter.next(), Some(Wed));
|
/// assert_eq!(iter.next(), Some(Wed));
|
||||||
/// assert_eq!(iter.next(), Some(Fri));
|
/// assert_eq!(iter.next(), Some(Fri));
|
||||||
/// assert_eq!(iter.next(), Some(Mon));
|
/// assert_eq!(iter.next(), Some(Mon));
|
||||||
/// assert_eq!(iter.next(), None);
|
/// assert_eq!(iter.next(), None);
|
||||||
/// ```
|
/// ```
|
||||||
pub const fn iter_from(self, start: Weekday) -> WeekdaySetIterFrom {
|
pub const fn iter(self, start: Weekday) -> WeekdaySetIter {
|
||||||
WeekdaySetIterFrom { days: self, start }
|
WeekdaySetIter { days: self, start }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns days that are in both `self` and `other`.
|
/// Returns days that are in both `self` and `other`.
|
||||||
@ -341,14 +341,14 @@ impl Debug for WeekdaySet {
|
|||||||
|
|
||||||
/// An iterator over a collection of weekdays, starting from a given day.
|
/// An iterator over a collection of weekdays, starting from a given day.
|
||||||
///
|
///
|
||||||
/// See `WeekdaySet::iter_from`.
|
/// See [`WeekdaySet::iter()`].
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct WeekdaySetIterFrom {
|
pub struct WeekdaySetIter {
|
||||||
pub days: WeekdaySet,
|
pub days: WeekdaySet,
|
||||||
pub start: Weekday,
|
pub start: Weekday,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Iterator for WeekdaySetIterFrom {
|
impl Iterator for WeekdaySetIter {
|
||||||
type Item = Weekday;
|
type Item = Weekday;
|
||||||
|
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
@ -368,7 +368,7 @@ impl Iterator for WeekdaySetIterFrom {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DoubleEndedIterator for WeekdaySetIterFrom {
|
impl DoubleEndedIterator for WeekdaySetIter {
|
||||||
fn next_back(&mut self) -> Option<Self::Item> {
|
fn next_back(&mut self) -> Option<Self::Item> {
|
||||||
if self.days.is_empty() {
|
if self.days.is_empty() {
|
||||||
return None;
|
return None;
|
||||||
@ -386,13 +386,13 @@ impl DoubleEndedIterator for WeekdaySetIterFrom {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ExactSizeIterator for WeekdaySetIterFrom {
|
impl ExactSizeIterator for WeekdaySetIter {
|
||||||
fn len(&self) -> usize {
|
fn len(&self) -> usize {
|
||||||
self.days.len().into()
|
self.days.len().into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FusedIterator for WeekdaySetIterFrom {}
|
impl FusedIterator for WeekdaySetIter {}
|
||||||
|
|
||||||
/// Print the collection as a slice-like list of weekdays.
|
/// Print the collection as a slice-like list of weekdays.
|
||||||
///
|
///
|
||||||
@ -407,7 +407,7 @@ impl FusedIterator for WeekdaySetIterFrom {}
|
|||||||
impl fmt::Display for WeekdaySet {
|
impl fmt::Display for WeekdaySet {
|
||||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||||
write!(f, "[")?;
|
write!(f, "[")?;
|
||||||
let mut iter = self.iter_from(Weekday::Mon);
|
let mut iter = self.iter(Weekday::Mon);
|
||||||
if let Some(first) = iter.next() {
|
if let Some(first) = iter.next() {
|
||||||
write!(f, "{first}")?;
|
write!(f, "{first}")?;
|
||||||
}
|
}
|
||||||
@ -463,8 +463,8 @@ mod tests {
|
|||||||
fn split_at_is_equivalent_to_iterating() {
|
fn split_at_is_equivalent_to_iterating() {
|
||||||
use Weekday::*;
|
use Weekday::*;
|
||||||
|
|
||||||
// `split_at` is used in `iter_from`, so we must not iterate
|
// `split_at()` is used in `iter()`, so we must not iterate
|
||||||
// over all days with `WeekdaySet::ALL.iter_from(Mon)`.
|
// over all days with `WeekdaySet::ALL.iter(Mon)`.
|
||||||
const WEEK: [Weekday; 7] = [Mon, Tue, Wed, Thu, Fri, Sat, Sun];
|
const WEEK: [Weekday; 7] = [Mon, Tue, Wed, Thu, Fri, Sat, Sun];
|
||||||
|
|
||||||
for weekdays in WeekdaySet::iter_all() {
|
for weekdays in WeekdaySet::iter_all() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user