pub struct HistoryRing { /* private fields */ }Expand description
LIFO ring buffer for yank/delete history (numbered registers 0-255).
§Example
use reovim_kernel::api::v1::*;
let mut ring = HistoryRing::new();
ring.push(RegisterContent::characterwise("first"));
ring.push(RegisterContent::characterwise("second"));
// Most recent is at index 0
assert_eq!(ring.get(0).map(|r| r.text.as_str()), Some("second"));
assert_eq!(ring.get(1).map(|r| r.text.as_str()), Some("first"));Implementations§
Source§impl HistoryRing
impl HistoryRing
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Create a history ring with custom capacity.
Sourcepub fn push(&mut self, content: RegisterContent)
pub fn push(&mut self, content: RegisterContent)
Push content to the front of the history.
The new entry becomes register 0. If the ring is full,
the oldest entry (register 9) is discarded.
Sourcepub fn get(&self, index: usize) -> Option<&RegisterContent>
pub fn get(&self, index: usize) -> Option<&RegisterContent>
Get an entry by index (0 = most recent).
Sourcepub fn get_by_index(&self, index: u8) -> Option<&RegisterContent>
pub fn get_by_index(&self, index: u8) -> Option<&RegisterContent>
Get an entry by u8 index (0 = most recent).
This is the typed accessor for Register::History(u8).
Returns None if the index is beyond the current history length.
Sourcepub fn get_numbered(&self, n: char) -> Option<RegisterContent>
pub fn get_numbered(&self, n: char) -> Option<RegisterContent>
Get an entry by numbered register character (‘0’-‘9’).
Returns None if the character is not a digit or the index
is beyond the current history length.
Sourcepub fn iter(&self) -> impl Iterator<Item = &RegisterContent>
pub fn iter(&self) -> impl Iterator<Item = &RegisterContent>
Iterate over entries in order (most recent first).
Trait Implementations§
Source§impl Clone for HistoryRing
impl Clone for HistoryRing
Source§fn clone(&self) -> HistoryRing
fn clone(&self) -> HistoryRing
Returns a duplicate of the value. Read more
1.0.0 · 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 HistoryRing
impl Debug for HistoryRing
Auto Trait Implementations§
impl Freeze for HistoryRing
impl RefUnwindSafe for HistoryRing
impl Send for HistoryRing
impl Sync for HistoryRing
impl Unpin for HistoryRing
impl UnsafeUnpin for HistoryRing
impl UnwindSafe for HistoryRing
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