pub trait Ordinal:
Sized
+ Eq
+ PartialEq
+ Ord
+ PartialOrd
+ Hash
+ Clone
+ Copy
+ Default
+ Display
+ Debug {
type IntegerType: Copy + Display;
// Required methods
fn first() -> Self;
fn next(self) -> Self;
fn into0(self) -> Self::IntegerType;
fn into1(self) -> Self::IntegerType;
fn try_from0(t: Self::IntegerType) -> Option<Self>;
fn try_from1(t: Self::IntegerType) -> Option<Self>;
// Provided methods
fn from0(t: Self::IntegerType) -> Self { ... }
fn from1(t: Self::IntegerType) -> Self { ... }
}
Expand description
An ordinal number type
See the module-level documentation for more.
Required Associated Types§
Sourcetype IntegerType: Copy + Display
type IntegerType: Copy + Display
This type by which this ordinal type is represented
Required Methods§
Sourcefn into0(self) -> Self::IntegerType
fn into0(self) -> Self::IntegerType
Returns the equivalent integer assuming the ordinal number is 0-based
Sourcefn into1(self) -> Self::IntegerType
fn into1(self) -> Self::IntegerType
Returns the equivalent integer assuming the ordinal number is 1-based
Sourcefn try_from0(t: Self::IntegerType) -> Option<Self>
fn try_from0(t: Self::IntegerType) -> Option<Self>
Tries to convert an integer to a 0-based ordinal number.
It returns None if the provided number is the highest number of that integer type. This fails because that number can’t be incremented by 1.
Sourcefn try_from1(t: Self::IntegerType) -> Option<Self>
fn try_from1(t: Self::IntegerType) -> Option<Self>
Tries to convert an integer to a 1-based ordinal number.
It returns None if the provided number is 0.
Provided Methods§
Sourcefn from0(t: Self::IntegerType) -> Self
fn from0(t: Self::IntegerType) -> Self
Converts an integer to a 0-based ordinal number.
§Panics
Panics if the provided number is the highest number of that integer type. This fails because that number can’t be incremented by 1.
Sourcefn from1(t: Self::IntegerType) -> Self
fn from1(t: Self::IntegerType) -> Self
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.