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 Freeze for String
impl RefUnwindSafe for String
impl Send for String
impl Sync for String
impl Unpin for String
impl UnwindSafe for String
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> ToStylishString for T
impl<T> ToStylishString for T
Source§fn to_stylish_string(&self) -> String
fn to_stylish_string(&self) -> String
Available on crate features
alloc
and macros
only.Converts the given value to a
stylish::String
. Read more