history now logs "cd" and "exit", history bug when starting a new session and inputting a new command then leaving will concat onto the old history's same line
This commit is contained in:
24
src/lib.rs
24
src/lib.rs
@ -7,26 +7,4 @@ pub mod ps;
|
||||
pub mod rc;
|
||||
pub mod vm;
|
||||
|
||||
mod valid_pbuf;
|
||||
|
||||
#[inline]
|
||||
pub fn shell_error<E: core::fmt::Display>(err: E) {
|
||||
color_print::ceprintln!("<bold,r>[!]:</> {err}")
|
||||
}
|
||||
|
||||
pub trait MapDisplay<T, E: core::fmt::Display> {
|
||||
fn map_or_display<F: FnOnce(T)>(self, f: F);
|
||||
fn map_or_display_none<R, F: FnOnce(T) -> Option<R>>(self, f: F) -> Option<R>;
|
||||
}
|
||||
impl<T, E: core::fmt::Display> MapDisplay<T, E> for Result<T, E> {
|
||||
///Map but display the error to stdout
|
||||
#[inline]
|
||||
fn map_or_display<F: FnOnce(T)>(self, f: F) {
|
||||
self.map_or_else(|e| shell_error(e), f)
|
||||
}
|
||||
///Map but display the error to stdout and return `None`
|
||||
#[inline]
|
||||
fn map_or_display_none<R, F: FnOnce(T) -> Option<R>>(self, f: F) -> Option<R> {
|
||||
self.map_or_else(|e| { shell_error(e); None }, f)
|
||||
}
|
||||
}
|
||||
mod valid_pbuf;
|
Reference in New Issue
Block a user