pub struct Luhn { /* private fields */ }
Expand description
Luhn represents a thing that can generate or validate the Luhn character for a given input.
Implementations§
Source§impl Luhn
impl Luhn
Sourcepub fn new<S>(alphabet: S) -> Result<Luhn, LuhnError>
pub fn new<S>(alphabet: S) -> Result<Luhn, LuhnError>
Create a new Luhn instance from anything that can be coerced to a
&str
.
Sourcepub fn generate<S>(&self, s: S) -> Result<char, LuhnError>
pub fn generate<S>(&self, s: S) -> Result<char, LuhnError>
Given an input string, generate the Luhn character.
Returns an error if the input string is empty, or contains a character that is not in the input alphabet.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Luhn
impl RefUnwindSafe for Luhn
impl Send for Luhn
impl Sync for Luhn
impl Unpin for Luhn
impl UnwindSafe for Luhn
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