pub struct LineReader { /* private fields */ }Expand description
A minimal line editor with command history.
Supports:
- Up/Down arrow keys to navigate command history
- Left/Right arrow keys to move the cursor within the line
- Home/End to jump to the beginning/end of the line
- Delete to remove the character under the cursor
- Backspace to remove the character before the cursor
- Ctrl-U to clear the line, Ctrl-K to kill to end of line
- Ctrl-W to delete the previous word
- Ctrl-A / Ctrl-E for Home / End
Implementations§
Source§impl LineReader
impl LineReader
Sourcepub fn new(max_history: usize) -> Self
pub fn new(max_history: usize) -> Self
Create a new LineReader with the given maximum history size.
Sourcepub fn read_line(
&mut self,
prompt: &str,
cancel_token: Option<CancellationToken>,
) -> Result<Option<String>>
pub fn read_line( &mut self, prompt: &str, cancel_token: Option<CancellationToken>, ) -> Result<Option<String>>
Read a line interactively with arrow-key history navigation.
Returns Ok(Some(line)) on success, Ok(None) on EOF (Ctrl-D).
Auto Trait Implementations§
impl Freeze for LineReader
impl RefUnwindSafe for LineReader
impl Send for LineReader
impl Sync for LineReader
impl Unpin for LineReader
impl UnsafeUnpin for LineReader
impl UnwindSafe for LineReader
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