pub struct PromptHistory { /* private fields */ }Expand description
History of submitted prompt lines.
cursor semantics:
None→ operator is at the live draft (newest).Some(i)→ operator is recallingentries[i].
Stepping past index 0 (Up at oldest) clamps; stepping past
the live draft (Down at newest) leaves cursor = None and
restores the saved draft.
Implementations§
Source§impl PromptHistory
impl PromptHistory
pub fn new() -> Self
pub fn with_capacity(cap: usize) -> Self
Sourcepub fn push(&mut self, line: &str)
pub fn push(&mut self, line: &str)
Append a submitted line. Empty lines are ignored. Two
consecutive identical entries are deduped (bash-style) so
hammering Enter doesn’t bury everything else under copies
of /status.
Sourcepub fn reset_cursor(&mut self)
pub fn reset_cursor(&mut self)
Cursor reset — call after a successful submission so the next Up starts from the newest entry again.
Sourcepub fn recall_prev(&mut self) -> Option<&str>
pub fn recall_prev(&mut self) -> Option<&str>
Up arrow — step toward older history. Returns the recalled
entry, or None if history is empty / already at oldest.
Sourcepub fn recall_next(&mut self) -> Option<&str>
pub fn recall_next(&mut self) -> Option<&str>
Down arrow — step toward newer history. Returns the
recalled entry, or None to signal “you’ve stepped past
the newest entry; restore the live draft” (the buffer
owns the saved draft and handles that branch).
Sourcepub const fn is_recalling(&self) -> bool
pub const fn is_recalling(&self) -> bool
True when the operator is currently navigating history (not editing the live draft).
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Trait Implementations§
Source§impl Clone for PromptHistory
impl Clone for PromptHistory
Source§fn clone(&self) -> PromptHistory
fn clone(&self) -> PromptHistory
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PromptHistory
impl Debug for PromptHistory
Source§impl Default for PromptHistory
impl Default for PromptHistory
Source§fn default() -> PromptHistory
fn default() -> PromptHistory
Auto Trait Implementations§
impl Freeze for PromptHistory
impl RefUnwindSafe for PromptHistory
impl Send for PromptHistory
impl Sync for PromptHistory
impl Unpin for PromptHistory
impl UnsafeUnpin for PromptHistory
impl UnwindSafe for PromptHistory
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more