pub trait Styleable: Sized {
// Provided methods
fn styled(self) -> Styled<Self> { ... }
fn styled_with(self, style: Style) -> Styled<Self> { ... }
}Expand description
Provided Methods§
Sourcefn styled(self) -> Styled<Self>
fn styled(self) -> Styled<Self>
Create a new Styled value from this value.
§Examples
use stylic::Styleable;
println!("{}", "Hello, world!".styled().red());Examples found in repository?
More examples
examples/demo.rs (line 4)
3fn main() {
4 let hello = "Hello".styled().bold().red().on_blue();
5
6 println!("{}", lazy_format!("{:b}", 12));
7
8 let world = lazy_format!("Wor{}ld", lazy_format!("he{}he", "haha").styled().blue())
9 .styled()
10 .cyan()
11 .inverted();
12
13 println!("{hello}, {world}!");
14
15 println!("{:?}", world.style);
16 println!("{:?}", world.to_string());
17
18 println!("{}", "strikethrough".styled().strikethrough());
19
20 println!(
21 "{}",
22 "Google".styled().bold().green().link("https://google.com")
23 );
24
25 println!("{}", "Hello".styled().underline_colored(48.into()));
26}Sourcefn styled_with(self, style: Style) -> Styled<Self>
fn styled_with(self, style: Style) -> Styled<Self>
Create a new Styled value from this value, with an existing style.
§Examples
use stylic::{Style, Styleable};
let style = Style::new().red();
println!("{}", "Hello, world!".styled_with(style));Examples found in repository?
examples/style.rs (line 6)
3fn main() {
4 let my_style = Style::new().bold().blue();
5
6 println!("{}!", "Hello".styled_with(my_style));
7
8 println!(
9 "{}",
10 "Rust Language"
11 .styled_with(my_style)
12 .link("https://rust-lang.org")
13 );
14}Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.