Enum spinoso_string::OrdError[][src]

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

impl OrdError[src]

pub const EXCEPTION_TYPE: &'static str[src]

OrdError corresponds to an ArgumentError Ruby exception.

#[must_use]pub const fn invalid_utf8_byte_sequence() -> Self[src]

Construct a new OrdError for an invalid UTF-8 byte sequence.

Only conventionally UTF-8 Strings 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));

#[must_use]pub const fn empty_string() -> Self[src]

Construct a new OrdError for an empty String.

Empty Strings have no first character. Empty Strings 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()));

#[must_use]pub const fn message(self) -> &'static str[src]

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

impl Clone for OrdError[src]

impl Copy for OrdError[src]

impl Debug for OrdError[src]

impl Display for OrdError[src]

impl Eq for OrdError[src]

impl Error for OrdError[src]

impl Hash for OrdError[src]

impl Ord for OrdError[src]

impl PartialEq<OrdError> for OrdError[src]

impl PartialOrd<OrdError> for OrdError[src]

impl StructuralEq for OrdError[src]

impl StructuralPartialEq for OrdError[src]

Auto Trait Implementations

impl RefUnwindSafe for OrdError

impl Send for OrdError

impl Sync for OrdError

impl Unpin for OrdError

impl UnwindSafe for OrdError

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.