[−][src]Enum shoebill::StrOrDoc
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
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
fn alloc(self, pr: &mut P) -> DocPtr<'p>
[src]
fn concat(self, other: impl Doclike<'p, P>, pr: &mut P) -> DocPtr<'p>
[src]
fn nest(self, amt: u32, pr: &mut P) -> DocPtr<'p>
[src]
fn nest_line(
self,
other: impl Doclike<'p, P>,
amt: u32,
pr: &mut P
) -> DocPtr<'p>
[src]
self,
other: impl Doclike<'p, P>,
amt: u32,
pr: &mut P
) -> DocPtr<'p>
fn nest_doc(
self,
other: impl Doclike<'p, P>,
amt: u32,
pr: &mut P
) -> DocPtr<'p>
[src]
self,
other: impl Doclike<'p, P>,
amt: u32,
pr: &mut P
) -> DocPtr<'p>
fn nest_doc_zero(
self,
other: impl Doclike<'p, P>,
amt: u32,
pr: &mut P
) -> DocPtr<'p>
[src]
self,
other: impl Doclike<'p, P>,
amt: u32,
pr: &mut P
) -> DocPtr<'p>
fn group(self, pr: &mut P) -> DocPtr<'p>
[src]
impl<'p> Eq for StrOrDoc<'p>
[src]
impl<'p, A> From<A> for StrOrDoc<'p> where
Cow<'p, str>: From<A>,
[src]
Cow<'p, str>: From<A>,
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]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<'p, A> Bracketable<'p> for A where
StrOrDoc<'p>: From<A>,
[src]
StrOrDoc<'p>: From<A>,
fn bracket(Self, u16) -> Brackets<'p>
[src]
fn bracket_never(self) -> Brackets<'p>
[src]
fn bracket_always(self) -> Brackets<'p>
[src]
impl<'p, A, P> Doclike<'p, P> for A where
P: HasPrinter<'p>,
Cow<'p, str>: From<A>,
[src]
P: HasPrinter<'p>,
Cow<'p, str>: From<A>,
fn alloc(Self, &mut P) -> DocPtr<'p>
[src]
fn concat(self, other: impl Doclike<'p, P>, pr: &mut P) -> DocPtr<'p>
[src]
fn nest(self, amt: u32, pr: &mut P) -> DocPtr<'p>
[src]
fn nest_line(
self,
other: impl Doclike<'p, P>,
amt: u32,
pr: &mut P
) -> DocPtr<'p>
[src]
self,
other: impl Doclike<'p, P>,
amt: u32,
pr: &mut P
) -> DocPtr<'p>
fn nest_doc(
self,
other: impl Doclike<'p, P>,
amt: u32,
pr: &mut P
) -> DocPtr<'p>
[src]
self,
other: impl Doclike<'p, P>,
amt: u32,
pr: &mut P
) -> DocPtr<'p>
fn nest_doc_zero(
self,
other: impl Doclike<'p, P>,
amt: u32,
pr: &mut P
) -> DocPtr<'p>
[src]
self,
other: impl Doclike<'p, P>,
amt: u32,
pr: &mut P
) -> DocPtr<'p>
fn group(self, pr: &mut P) -> DocPtr<'p>
[src]
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
fn equivalent(&self, key: &K) -> bool
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,