pub struct History { /* private fields */ }Expand description
Calculator history manager
Tracks past calculations for display and recall. Implements a bounded queue to prevent unbounded memory growth.
Implementations§
Source§impl History
impl History
Sourcepub const DEFAULT_MAX_ENTRIES: usize = 100
pub const DEFAULT_MAX_ENTRIES: usize = 100
Default maximum history size
Sourcepub fn with_capacity(max_entries: usize) -> Self
pub fn with_capacity(max_entries: usize) -> Self
Creates a history with custom maximum size
Sourcepub fn push(&mut self, entry: HistoryEntry)
pub fn push(&mut self, entry: HistoryEntry)
Adds an entry to the history
Sourcepub fn record(&mut self, expression: &str, result: f64)
pub fn record(&mut self, expression: &str, result: f64)
Adds a calculation result to the history
Sourcepub fn max_entries(&self) -> usize
pub fn max_entries(&self) -> usize
Returns the maximum number of entries
Sourcepub fn iter(&self) -> impl Iterator<Item = &HistoryEntry>
pub fn iter(&self) -> impl Iterator<Item = &HistoryEntry>
Returns an iterator over the entries (oldest first)
Sourcepub fn iter_rev(&self) -> impl Iterator<Item = &HistoryEntry>
pub fn iter_rev(&self) -> impl Iterator<Item = &HistoryEntry>
Returns an iterator over the entries (newest first)
Sourcepub fn last(&self) -> Option<&HistoryEntry>
pub fn last(&self) -> Option<&HistoryEntry>
Returns the most recent entry
Sourcepub fn first(&self) -> Option<&HistoryEntry>
pub fn first(&self) -> Option<&HistoryEntry>
Returns the oldest entry
Sourcepub fn get(&self, index: usize) -> Option<&HistoryEntry>
pub fn get(&self, index: usize) -> Option<&HistoryEntry>
Returns the entry at the given index (0 = oldest)
Sourcepub fn last_n(&self, n: usize) -> Vec<&HistoryEntry>
pub fn last_n(&self, n: usize) -> Vec<&HistoryEntry>
Returns the last n entries (newest first)
Sourcepub fn export_formatted(&self) -> String
pub fn export_formatted(&self) -> String
Exports history to a formatted string
Trait Implementations§
Auto Trait Implementations§
impl Freeze for History
impl RefUnwindSafe for History
impl Send for History
impl Sync for History
impl Unpin for History
impl UnsafeUnpin for History
impl UnwindSafe for History
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