elegance 0.4.0

A pretty-printing library for Rust with a focus on speed and compactness.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use std::ops::Deref;

/// A borrowed or owned string.
pub enum CowString<'a, T: AsRef<str> = String> {
    Borrowed(&'a str),
    Owned(T),
}

impl<T: AsRef<str>> Deref for CowString<'_, T> {
    type Target = str;

    fn deref(&self) -> &Self::Target {
        match self {
            CowString::Borrowed(b) => b,
            CowString::Owned(o) => o.as_ref(),
        }
    }
}