pub enum OrdError {
InvalidUtf8ByteSequence,
EmptyString,
}
Variants§
InvalidUtf8ByteSequence
The first character in a conventionally UTF-8 String
is an invalid
UTF-8 byte sequence.
EmptyString
The given String
is empty and has no first character.
Implementations§
Source§impl OrdError
impl OrdError
Sourcepub const EXCEPTION_TYPE: &'static str = "ArgumentError"
pub const EXCEPTION_TYPE: &'static str = "ArgumentError"
OrdError
corresponds to an ArgumentError
Ruby exception.
Sourcepub const fn invalid_utf8_byte_sequence() -> Self
pub const fn invalid_utf8_byte_sequence() -> Self
Construct a new OrdError
for an invalid UTF-8 byte sequence.
Only conventionally UTF-8 String
s can generate this error.
§Examples
use spinoso_string::{OrdError, String};
let s = String::utf8(b"\xFFabc".to_vec());
assert_eq!(s.ord(), Err(OrdError::invalid_utf8_byte_sequence()));
let s = String::binary(b"\xFFabc".to_vec());
assert_eq!(s.ord(), Ok(0xFF));
Sourcepub const fn empty_string() -> Self
pub const fn empty_string() -> Self
Construct a new OrdError
for an empty String
.
Empty String
s have no first character. Empty String
s with any
encoding return this error.
§Examples
use spinoso_string::{OrdError, String};
let s = String::utf8(b"\xFFabc".to_vec());
assert_eq!(s.ord(), Err(OrdError::invalid_utf8_byte_sequence()));
Sourcepub const fn message(self) -> &'static str
pub const fn message(self) -> &'static str
Error message for this OrdError
.
This message is suitable for generating an ArgumentError
exception
from this OrdError
.
§Examples
assert_eq!(
OrdError::invalid_utf8_byte_sequence().message(),
"invalid byte sequence in UTF-8"
);
assert_eq!(OrdError::empty_string().message(), "empty string");
Trait Implementations§
Source§impl Error for OrdError
impl Error for OrdError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Source§impl Ord for OrdError
impl Ord for OrdError
Source§impl PartialOrd for OrdError
impl PartialOrd for OrdError
impl Copy for OrdError
impl Eq for OrdError
impl StructuralPartialEq for OrdError
Auto Trait Implementations§
impl Freeze for OrdError
impl RefUnwindSafe for OrdError
impl Send for OrdError
impl Sync for OrdError
impl Unpin for OrdError
impl UnwindSafe for OrdError
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