[][src]Struct tinyvec_string::arraystring::CapacityOverflowError

pub struct CapacityOverflowError<S> { /* fields omitted */ }

An error was caused converting another string type into an ArrayString.

This type contains the amount by which the capacity was overflown, and the input string (when possible).

Examples

use std::convert::TryFrom;
let result = ArrayString::<[u8; 3]>::try_from("foobar");

assert!(result.is_err());
let err: CapacityOverflowError<&str> = result.unwrap_err();

assert_eq!(err.overflow_amount(), 3);
assert_eq!(err.into_inner(), "foobar");

Implementations

impl<S> CapacityOverflowError<S>[src]

pub fn overflow_amount(&self) -> usize[src]

Get the amount by which the capacity was overflown, i.e. the amount of extra capacity that would've been needed to store the string.

pub fn into_inner(self) -> S[src]

Retrieve the input string.

Examples

This could be used to retrieve a String that failed to convert:

use std::convert::TryFrom;
let heap_string = String::from("a very long string");
let result = ArrayString::<[u8; 5]>::try_from(heap_string);

assert!(result.is_err());
let err: CapacityOverflowError<String> = result.unwrap_err();
let return_of_the_heap_string = err.into_inner();

assert_eq!(return_of_the_heap_string, String::from("a very long string"));

Trait Implementations

impl<S: Clone> Clone for CapacityOverflowError<S>[src]

impl<S: Copy> Copy for CapacityOverflowError<S>[src]

impl<S: Debug> Debug for CapacityOverflowError<S>[src]

impl<S: Display> Display for CapacityOverflowError<S>[src]

impl<S: Eq> Eq for CapacityOverflowError<S>[src]

impl<S: Ord> Ord for CapacityOverflowError<S>[src]

impl<S: PartialEq> PartialEq<CapacityOverflowError<S>> for CapacityOverflowError<S>[src]

impl<S: PartialOrd> PartialOrd<CapacityOverflowError<S>> for CapacityOverflowError<S>[src]

impl<S> StructuralEq for CapacityOverflowError<S>[src]

impl<S> StructuralPartialEq for CapacityOverflowError<S>[src]

Auto Trait Implementations

impl<S> RefUnwindSafe for CapacityOverflowError<S> where
    S: RefUnwindSafe
[src]

impl<S> Send for CapacityOverflowError<S> where
    S: Send
[src]

impl<S> Sync for CapacityOverflowError<S> where
    S: Sync
[src]

impl<S> Unpin for CapacityOverflowError<S> where
    S: Unpin
[src]

impl<S> UnwindSafe for CapacityOverflowError<S> where
    S: UnwindSafe
[src]

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.