Struct css_modules::Module
source · pub struct Module {
pub name: String,
pub stylesheet: String,
pub classes: HashMap<String, String>,
}
Expand description
A CSS Module
Fields§
§name: String
§stylesheet: String
§classes: HashMap<String, String>
Implementations§
source§impl Module
impl Module
sourcepub fn contains(&self, class: &str) -> bool
pub fn contains(&self, class: &str) -> bool
Does the module contain a class?
use css_modules::Module;
let css = Module::new("my_module", ".myClass {}");
assert!(css.contains("myClass"));
sourcepub fn get(&self, class: &str) -> String
pub fn get(&self, class: &str) -> String
Get the alias of a class if it exists, otherwise return the one we were given.
use css_modules::Module;
let css = Module::new("my_module", ".myClass {}");
assert_ne!("myClass", css.get("myClass"));
assert_eq!("notMyClass", css.get("notMyClass"));
Examples found in repository?
examples/simple/main.rs (line 13)
5 6 7 8 9 10 11 12 13 14 15 16 17
fn main() {
let css = include_css_module!("main.css");
let html = format!(
r#"<!DOCTYPE html>
<style type="text/css">{stylesheet}</style>
<p class="{messageClass}">Hello World</p>"#,
stylesheet = css.stylesheet,
messageClass = css.get("message")
);
println!("{}", html);
}
Trait Implementations§
source§impl PartialEq for Module
impl PartialEq for Module
impl StructuralPartialEq for Module
Auto Trait Implementations§
impl Freeze for Module
impl RefUnwindSafe for Module
impl Send for Module
impl Sync for Module
impl Unpin for Module
impl UnwindSafe for Module
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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)