pub struct Stylesheet { /* private fields */ }
Implementations§
Source§impl Stylesheet
impl Stylesheet
Sourcepub fn new() -> Stylesheet
pub fn new() -> Stylesheet
Construct a new stylesheet
Sourcepub fn add(
self,
name: impl Into<Selector>,
declarations: impl Into<Style>,
) -> Stylesheet
pub fn add( self, name: impl Into<Selector>, declarations: impl Into<Style>, ) -> Stylesheet
Add a segment to the stylesheet.
Using style strings:
let stylesheet = Stylesheet::new()
.add("message header * code", "weight: bold; fg: red");
assert_eq!(stylesheet.get(&["message", "header", "error", "code"]),
Some(Style("weight: bold; fg: red")))
Using typed styles:
let stylesheet = Stylesheet::new()
.add("message header * code", Style::new().bold().fg(Color::Red));
assert_eq!(stylesheet.get(&["message", "header", "error", "code"]),
Some(Style("weight: bold; fg: red")))
Sourcepub fn get(&self, names: &[&'static str]) -> Option<Style>
pub fn get(&self, names: &[&'static str]) -> Option<Style>
Get the style associated with a nesting.
let stylesheet = Stylesheet::new()
.add("message ** code", "fg: blue")
.add("message header * code", "weight: bold; fg: red");
let style = stylesheet.get(&["message", "header", "error", "code"]);
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Stylesheet
impl RefUnwindSafe for Stylesheet
impl Send for Stylesheet
impl Sync for Stylesheet
impl Unpin for Stylesheet
impl UnwindSafe for Stylesheet
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