pub struct CounterScopeStack {
counters: BTreeMap<String, Vec<i64>>,
}Expand description
カウンタのスコープスタック管理
Fields§
§counters: BTreeMap<String, Vec<i64>>カウンタ名 -> スコープスタック(外側から内側への値のリスト)
Implementations§
Source§impl CounterScopeStack
impl CounterScopeStack
pub fn new() -> Self
Sourcepub fn to_flat_map(&self) -> BTreeMap<String, i64>
pub fn to_flat_map(&self) -> BTreeMap<String, i64>
現在の最深スコープの値だけをフラットマップとして取り出す。
Sourcepub fn push_reset(&mut self, name: &str, value: i64)
pub fn push_reset(&mut self, name: &str, value: i64)
counter-reset: name value を適用する。
仕様(CSS Lists and Counters §3):
要素に counter-reset がある場合、その名前の新しいカウンタスコープをスタックにプッシュする。
Sourcepub fn increment(&mut self, name: &str, value: i64)
pub fn increment(&mut self, name: &str, value: i64)
counter-increment: name value を適用する。
仕様: スタックの最深(最も内側)のカウンタに value を加算する。
もしまだ一度も reset されていない場合は、暗黙のルートスコープ(初期値 0)を生成して加算する。
Sourcepub fn set(&mut self, name: &str, value: i64)
pub fn set(&mut self, name: &str, value: i64)
counter-set: name value を適用する。
仕様: 最深スコープの値を上書きする。スタックが空なら暗黙のルートスコープを作成。
Sourcepub fn get_current(&self, name: &str) -> i64
pub fn get_current(&self, name: &str) -> i64
現在(最深スコープ)のカウンタ値を取得する。 スコープが存在しない場合は 0 を返す。
Sourcepub fn format_counter(
&self,
name: &str,
style: Option<&str>,
counter_styles: &[CounterStyleDef],
) -> String
pub fn format_counter( &self, name: &str, style: Option<&str>, counter_styles: &[CounterStyleDef], ) -> String
counter(name, style) の書式化文字列を生成する。
Sourcepub fn format_counters(
&self,
name: &str,
sep: &str,
style: Option<&str>,
counter_styles: &[CounterStyleDef],
) -> String
pub fn format_counters( &self, name: &str, sep: &str, style: Option<&str>, counter_styles: &[CounterStyleDef], ) -> String
counters(name, sep, style) の書式化文字列を生成する。
すべてのネストレベルの値を sep で連結する。
Trait Implementations§
Source§impl Clone for CounterScopeStack
impl Clone for CounterScopeStack
Source§fn clone(&self) -> CounterScopeStack
fn clone(&self) -> CounterScopeStack
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CounterScopeStack
impl Debug for CounterScopeStack
Source§impl Default for CounterScopeStack
impl Default for CounterScopeStack
Source§fn default() -> CounterScopeStack
fn default() -> CounterScopeStack
Returns the “default value” for a type. Read more
impl Eq for CounterScopeStack
Source§impl PartialEq for CounterScopeStack
impl PartialEq for CounterScopeStack
impl StructuralPartialEq for CounterScopeStack
Auto Trait Implementations§
impl Freeze for CounterScopeStack
impl RefUnwindSafe for CounterScopeStack
impl Send for CounterScopeStack
impl Sync for CounterScopeStack
impl Unpin for CounterScopeStack
impl UnsafeUnpin for CounterScopeStack
impl UnwindSafe for CounterScopeStack
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,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.