Struct stylish_core::String
source · [−]pub struct String { /* private fields */ }
Available on crate feature
alloc
only.Expand description
An attributed version of alloc::string::String
which has a specific
Style
associated with each character.
The main interfaces to create an instance of this are stylish::format!
and impl Write for String
, and to inspect the content
impl Display for String
.
You can create an instance via stylish::format!
:
let _: stylish::String = stylish::format!("Hello {:(fg=green)}!", "World");
You can append extra data via stylish::write!
:
use stylish::Write;
let mut s = stylish::String::new();
stylish::write!(s, "{:(fg=magenta)}", "fuchsia")?;
To use the attributed data you must then write this string to a sink using
the {:s}
trait-selector.
use stylish::Write;
let mut s = stylish::format!("Hello {:(fg=green)}!", "World");
stylish::write!(s, " Is it {:(fg=magenta)} or?", "fuchsia")?;
assert_eq!(
stylish::html::format!("{:s}", s),
"Hello <span style=color:green>World</span>! \
Is it <span style=color:magenta>fuchsia</span> or?",
);
Implementations
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for String
impl Send for String
impl Sync for String
impl Unpin for String
impl UnwindSafe for String
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more