pub enum AndBehavior {
None,
LastGroup,
OnlyUnderThousand,
All,
}
Expand description
Signals when the word “and” should be used in an output
Variants§
None
Indicates that the word “and” is not to be used.
Examples
use numbers_into_words::{to_word, AndBehavior};
assert_eq!(
to_word(350_000_000, AndBehavior::None),
"three-hundred fifty million".to_string()
);
assert_eq!(
to_word(350_000_430, AndBehavior::None),
"three-hundred fifty million, four-hundred thirty".to_string()
);
assert_eq!(
to_word(2_859, AndBehavior::None),
"two thousand, eight-hundred fifty-nine".to_string()
);
assert_eq!(
to_word(731, AndBehavior::None),
"seven-hundred thirty-one".to_string()
);
LastGroup
Indicates that the word “and” is to be used only in last group (hundreds, tens, and one digit).
Examples
use numbers_into_words::{to_word, AndBehavior};
assert_eq!(
to_word(350_000_000, AndBehavior::LastGroup),
"three-hundred fifty million".to_string()
);
assert_eq!(
to_word(350_000_430, AndBehavior::LastGroup),
"three-hundred fifty million, four-hundred and thirty".to_string()
);
assert_eq!(
to_word(2_859, AndBehavior::LastGroup),
"two thousand, eight-hundred and fifty-nine".to_string()
);
assert_eq!(
to_word(731, AndBehavior::LastGroup),
"seven-hundred and thirty-one".to_string()
);
OnlyUnderThousand
Indicates that the word “and” is to be used only if the number is less than 1000.
Examples
use numbers_into_words::{to_word, AndBehavior};
assert_eq!(
to_word(350_000_000, AndBehavior::OnlyUnderThousand),
"three-hundred fifty million".to_string()
);
assert_eq!(
to_word(350_000_430, AndBehavior::OnlyUnderThousand),
"three-hundred fifty million, four-hundred thirty".to_string()
);
assert_eq!(
to_word(2_859, AndBehavior::OnlyUnderThousand),
"two thousand, eight-hundred fifty-nine".to_string()
);
assert_eq!(
to_word(731, AndBehavior::OnlyUnderThousand),
"seven-hundred and thirty-one".to_string()
);
All
Indicates that the word “and” is to be used in every group.
Examples
use numbers_into_words::{to_word, AndBehavior};
assert_eq!(
to_word(350_000_000, AndBehavior::All),
"three-hundred and fifty million".to_string()
);
assert_eq!(
to_word(350_000_430, AndBehavior::All),
"three-hundred and fifty million, four-hundred and thirty".to_string()
);
assert_eq!(
to_word(2_859, AndBehavior::All),
"two thousand, eight-hundred and fifty-nine".to_string()
);
assert_eq!(
to_word(731, AndBehavior::All),
"seven-hundred and thirty-one".to_string()
);
Trait Implementations§
source§impl Clone for AndBehavior
impl Clone for AndBehavior
source§fn clone(&self) -> AndBehavior
fn clone(&self) -> AndBehavior
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for AndBehavior
impl Debug for AndBehavior
source§impl PartialEq<AndBehavior> for AndBehavior
impl PartialEq<AndBehavior> for AndBehavior
source§fn eq(&self, other: &AndBehavior) -> bool
fn eq(&self, other: &AndBehavior) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl Copy for AndBehavior
impl Eq for AndBehavior
impl StructuralEq for AndBehavior
impl StructuralPartialEq for AndBehavior
Auto Trait Implementations§
impl RefUnwindSafe for AndBehavior
impl Send for AndBehavior
impl Sync for AndBehavior
impl Unpin for AndBehavior
impl UnwindSafe for AndBehavior
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