pub struct CssVars {
own: BTreeMap<String, String>,
parent: Option<Rc<CssVars>>,
depth: u16,
hash: (u64, u64),
}Expand description
ある要素のスコープで有効な CSS 変数(--foo)。親の表を共有し、その要素で宣言した分だけを持つ層。
【2026-11-05】以前は Rc<BTreeMap> を Rc::make_mut で書き換えており、変数を 1 つでも宣言する要素ごとに
祖先から受け継いだ表を丸ごと写していた(YouTube は数百の --yt-* を持ち、多くの要素が宣言する)。
層が深くなりすぎたら(MAX_DEPTH)平らにして引く手間を抑える。
Fields§
§own: BTreeMap<String, String>§parent: Option<Rc<CssVars>>§depth: u16§hash: (u64, u64)中身の要約(親の要約と自分の分から作る。スタイルの使い回しの鍵に使う)。空の表は (0, 0)。
Implementations§
Source§impl CssVars
impl CssVars
const MAX_DEPTH: u16 = 8
Sourcepub fn layered(parent: &Rc<CssVars>, own: BTreeMap<String, String>) -> Self
pub fn layered(parent: &Rc<CssVars>, own: BTreeMap<String, String>) -> Self
parent の上に own を重ねた表。
Sourcepub(crate) fn content_hash(&self) -> (u64, u64)
pub(crate) fn content_hash(&self) -> (u64, u64)
中身の要約(同じ親に同じ宣言を重ねた表は同じ値。中身が違えばほぼ確実に違う値)。
pub fn get(&self, name: &str) -> Option<&String>
pub fn is_empty(&self) -> bool
Trait Implementations§
Auto Trait Implementations§
impl !Send for CssVars
impl !Sync for CssVars
impl Freeze for CssVars
impl RefUnwindSafe for CssVars
impl Unpin for CssVars
impl UnsafeUnpin for CssVars
impl UnwindSafe for CssVars
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