[][src]Enum shoebill::StrOrDoc

pub enum StrOrDoc<'p> {
    S(Cow<'p, str>),
    D(DocPtr<'p>),
}

A tagged union of either a Cow string, or a DocPtr. By using this type in conjuction with the Doclike trait, we get a pretty large amount of code reuse while cutting down on syntax noise since in many cases we can treat string slices, owned strings, and DocPtr items in the exact same way with the only overhead being that of dealing with the enum (IE there are no extra allocations or clones).

Variants

S(Cow<'p, str>)
D(DocPtr<'p>)

Trait Implementations

impl<'p> Clone for StrOrDoc<'p>[src]

impl<'p> Debug for StrOrDoc<'p>[src]

impl<'p, P: HasPrinter<'p>> Doclike<'p, P> for StrOrDoc<'p>[src]

StrOrDoc is doclike; in the case of a doc, you just get the doc back. In the case of a Cow string, we allocate defer to the implementation that's generic over any A such that A can become a Cow string

impl<'p> Eq for StrOrDoc<'p>[src]

impl<'p, A> From<A> for StrOrDoc<'p> where
    Cow<'p, str>: From<A>, 
[src]

Can create a StrOrDoc from anything that can become a Cow string (so a CowStr, a string slice, or an owned string)

impl<'p> From<DocPtr<'p>> for StrOrDoc<'p>[src]

Can create a StrOrDoc from a DocPtr

impl<'p> Hash for StrOrDoc<'p>[src]

impl<'p> PartialEq<StrOrDoc<'p>> for StrOrDoc<'p>[src]

impl<'p> StructuralEq for StrOrDoc<'p>[src]

impl<'p> StructuralPartialEq for StrOrDoc<'p>[src]

Auto Trait Implementations

impl<'p> RefUnwindSafe for StrOrDoc<'p>

impl<'p> Send for StrOrDoc<'p>

impl<'p> Sync for StrOrDoc<'p>

impl<'p> Unpin for StrOrDoc<'p>

impl<'p> UnwindSafe for StrOrDoc<'p>

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<'p, A> Bracketable<'p> for A where
    StrOrDoc<'p>: From<A>, 
[src]

impl<'p, A, P> Doclike<'p, P> for A where
    P: HasPrinter<'p>,
    Cow<'p, str>: From<A>, 
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?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, 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.