pub struct CountAccumulator { /* private fields */ }Expand description
Digit-prefix count accumulator for the vim grammar.
Tracks a running count as digits are typed. Resets when consumed.
Implementations§
Source§impl CountAccumulator
impl CountAccumulator
Sourcepub const fn peek(&self) -> u32
pub const fn peek(&self) -> u32
Peek at the current count without resetting. Returns 0 when empty.
Sourcepub fn try_accumulate(&mut self, ch: char) -> bool
pub fn try_accumulate(&mut self, ch: char) -> bool
Try to accumulate a digit character.
Returns true if the digit was consumed; false otherwise —
either because ch is not an ASCII digit, OR because it’s 0
with an empty buffer (vim’s LineStart-vs-digit-0 split). The
caller routes false results through the keymap.
Saturates at u32::MAX to guard pathological input.
Sourcepub fn take_or(&mut self, default: u32) -> u32
pub fn take_or(&mut self, default: u32) -> u32
Drain the buffer, returning the count or default if empty.
Resets state.
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Reset the buffer without taking. Used when a non-chord-starter
key arrives and the digits need to be replayed elsewhere — call
[drain_as_digits] first if you need the chars.
Sourcepub fn drain_as_digits(&mut self) -> String
pub fn drain_as_digits(&mut self) -> String
Drain the buffer as the digit characters that were typed,
preserving order. Used by the host to replay digits into the
engine FSM when the next key is not a hjkl-vim binding (e.g.
engine still owns p / u / etc. and needs count via FSM).
Resets state. Returns empty string when buffer is empty.
Trait Implementations§
Source§impl Clone for CountAccumulator
impl Clone for CountAccumulator
Source§fn clone(&self) -> CountAccumulator
fn clone(&self) -> CountAccumulator
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CountAccumulator
impl Debug for CountAccumulator
Source§impl Default for CountAccumulator
impl Default for CountAccumulator
Source§fn default() -> CountAccumulator
fn default() -> CountAccumulator
impl Eq for CountAccumulator
Source§impl PartialEq for CountAccumulator
impl PartialEq for CountAccumulator
Source§fn eq(&self, other: &CountAccumulator) -> bool
fn eq(&self, other: &CountAccumulator) -> bool
self and other values to be equal, and is used by ==.