mirror of
https://github.com/chronotope/chrono.git
synced 2025-09-30 06:21:56 +00:00
strftime: re-order items to keep impls together
This commit is contained in:
parent
757a8b0226
commit
0ee2172fb9
@ -427,33 +427,6 @@ impl<'a> StrftimeItems<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
const HAVE_ALTERNATES: &str = "z";
|
||||
|
||||
impl<'a> Iterator for StrftimeItems<'a> {
|
||||
type Item = Item<'a>;
|
||||
|
||||
fn next(&mut self) -> Option<Item<'a>> {
|
||||
// We have items queued to return from a specifier composed of multiple formatting items.
|
||||
if let Some((item, remainder)) = self.queue.split_first() {
|
||||
self.queue = remainder;
|
||||
return Some(item.clone());
|
||||
}
|
||||
|
||||
// We are in the middle of parsing the localized formatting string of a specifier.
|
||||
#[cfg(feature = "unstable-locales")]
|
||||
if !self.locale_str.is_empty() {
|
||||
let (remainder, item) = self.parse_next_item(self.locale_str)?;
|
||||
self.locale_str = remainder;
|
||||
return Some(item);
|
||||
}
|
||||
|
||||
// Normal: we are parsing the formatting string.
|
||||
let (remainder, item) = self.parse_next_item(self.remainder)?;
|
||||
self.remainder = remainder;
|
||||
Some(item)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> StrftimeItems<'a> {
|
||||
fn error<'b>(
|
||||
&mut self,
|
||||
@ -779,6 +752,33 @@ impl<'a> StrftimeItems<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Iterator for StrftimeItems<'a> {
|
||||
type Item = Item<'a>;
|
||||
|
||||
fn next(&mut self) -> Option<Item<'a>> {
|
||||
// We have items queued to return from a specifier composed of multiple formatting items.
|
||||
if let Some((item, remainder)) = self.queue.split_first() {
|
||||
self.queue = remainder;
|
||||
return Some(item.clone());
|
||||
}
|
||||
|
||||
// We are in the middle of parsing the localized formatting string of a specifier.
|
||||
#[cfg(feature = "unstable-locales")]
|
||||
if !self.locale_str.is_empty() {
|
||||
let (remainder, item) = self.parse_next_item(self.locale_str)?;
|
||||
self.locale_str = remainder;
|
||||
return Some(item);
|
||||
}
|
||||
|
||||
// Normal: we are parsing the formatting string.
|
||||
let (remainder, item) = self.parse_next_item(self.remainder)?;
|
||||
self.remainder = remainder;
|
||||
Some(item)
|
||||
}
|
||||
}
|
||||
|
||||
const HAVE_ALTERNATES: &str = "z";
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::StrftimeItems;
|
||||
|
Loading…
x
Reference in New Issue
Block a user