titan_html_core/stylerule.rs
1use std::hash::Hash;
2
3#[derive(Clone, Debug, PartialEq, Eq, Hash)]
4pub struct StyleRule {
5 pub rule: &'static str,
6 pub styles: &'static [(&'static str, &'static str)],
7}
8
9impl ToString for StyleRule {
10 fn to_string(&self) -> String {
11 let styles = self
12 .styles
13 .iter()
14 .map(|(key, value)| format!("{key}:{value};"))
15 .collect::<Vec<String>>()
16 .join("");
17
18 let total = format!(".{}{{{}}}", self.rule, styles);
19
20 total
21 }
22}