forked from unicode-org/icu4x
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
31 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// This file is part of ICU4X. For terms of use, please see the file | ||
// called LICENSE at the top level of the ICU4X source tree | ||
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). | ||
|
||
/// A container for 0, 1, or 2 elements that owns its data and supports iteration | ||
#[derive(Copy, Clone)] | ||
pub(crate) enum ZeroOneOrTwo<T> { | ||
Zero, | ||
One(T), | ||
Two(T, T), | ||
} | ||
|
||
impl<T: Copy> Iterator for ZeroOneOrTwo<T> { | ||
type Item = T; | ||
fn next(&mut self) -> Option<Self::Item> { | ||
match *self { | ||
ZeroOneOrTwo::Zero => None, | ||
ZeroOneOrTwo::One(a) => { | ||
*self = ZeroOneOrTwo::Zero; | ||
Some(a) | ||
} | ||
ZeroOneOrTwo::Two(a, b) => { | ||
*self = ZeroOneOrTwo::One(b); | ||
Some(a) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,6 +69,7 @@ | |
#![warn(missing_docs)] | ||
|
||
mod error; | ||
mod helpers; | ||
mod registry; | ||
mod source; | ||
mod transform; | ||
|