pub enum CheckPosition {
Start,
End,
Index(i8),
}Expand description
Index-based check digit position.
The check digit can be placed at any position in the code using positive or negative indexing:
0: Start (first position)-1: End (last position, default)- Positive N: Position N from start
- Negative -N: Position N from end
§Examples
use promocrypt_core::CheckPosition;
let pos = CheckPosition::End;
assert_eq!(pos.to_index(10), 9);
let pos = CheckPosition::Start;
assert_eq!(pos.to_index(10), 0);
let pos = CheckPosition::Index(4);
assert_eq!(pos.to_index(10), 4);
let pos = CheckPosition::Index(-3);
assert_eq!(pos.to_index(10), 7);Variants§
Start
Check digit at the start of the code (index 0)
End
Check digit at the end of the code (index -1)
Index(i8)
Check digit at specific index (positive or negative)
Implementations§
Trait Implementations§
Source§impl Clone for CheckPosition
impl Clone for CheckPosition
Source§fn clone(&self) -> CheckPosition
fn clone(&self) -> CheckPosition
Returns a duplicate 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 CheckPosition
impl Debug for CheckPosition
Source§impl Default for CheckPosition
impl Default for CheckPosition
Source§fn default() -> CheckPosition
fn default() -> CheckPosition
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for CheckPosition
impl<'de> Deserialize<'de> for CheckPosition
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for CheckPosition
impl Display for CheckPosition
Source§impl FromStr for CheckPosition
impl FromStr for CheckPosition
Source§impl PartialEq for CheckPosition
impl PartialEq for CheckPosition
Source§impl Serialize for CheckPosition
impl Serialize for CheckPosition
impl Copy for CheckPosition
impl Eq for CheckPosition
impl StructuralPartialEq for CheckPosition
Auto Trait Implementations§
impl Freeze for CheckPosition
impl RefUnwindSafe for CheckPosition
impl Send for CheckPosition
impl Sync for CheckPosition
impl Unpin for CheckPosition
impl UnwindSafe for CheckPosition
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