diff --git a/src/bin/fish_indent.rs b/src/bin/fish_indent.rs index 87bc41b47..a013595fa 100644 --- a/src/bin/fish_indent.rs +++ b/src/bin/fish_indent.rs @@ -30,7 +30,7 @@ use fish::fds::set_cloexec; use fish::fprintf; #[allow(unused_imports)] -use fish::future::{IsOkAnd, IsSomeAnd, IsSorted}; +use fish::future::{IsSomeAnd, IsSorted}; use fish::global_safety::RelaxedAtomicBool; use fish::highlight::{colorize, highlight_shell, HighlightRole, HighlightSpec}; use fish::libc::setlinebuf; diff --git a/src/builtins/test.rs b/src/builtins/test.rs index e18235843..17a3f5a29 100644 --- a/src/builtins/test.rs +++ b/src/builtins/test.rs @@ -7,7 +7,6 @@ mod test_expressions { use super::*; #[allow(unused_imports)] - use crate::future::IsOkAnd; use crate::nix::isatty; use crate::wutil::{ file_id_for_path, fish_wcswidth, lwstat, waccess, wcstod::wcstod, wcstoi_opts, wstat, diff --git a/src/future.rs b/src/future.rs index 7c0d5b609..52002038c 100644 --- a/src/future.rs +++ b/src/future.rs @@ -3,18 +3,10 @@ pub trait IsSomeAnd { type Type; #[allow(clippy::wrong_self_convention)] - fn is_some_and(self, s: impl FnOnce(Self::Type) -> bool) -> bool; - #[allow(clippy::wrong_self_convention)] fn is_none_or(self, s: impl FnOnce(Self::Type) -> bool) -> bool; } impl IsSomeAnd for Option { type Type = T; - fn is_some_and(self, f: impl FnOnce(T) -> bool) -> bool { - match self { - Some(v) => f(v), - None => false, - } - } fn is_none_or(self, f: impl FnOnce(T) -> bool) -> bool { match self { Some(v) => f(v), @@ -23,31 +15,6 @@ fn is_none_or(self, f: impl FnOnce(T) -> bool) -> bool { } } -pub trait IsOkAnd { - type Type; - type Error; - #[allow(clippy::wrong_self_convention)] - fn is_ok_and(self, s: impl FnOnce(Self::Type) -> bool) -> bool; - #[allow(clippy::wrong_self_convention)] - fn is_err_and(self, s: impl FnOnce(Self::Error) -> bool) -> bool; -} -impl IsOkAnd for Result { - type Type = T; - type Error = E; - fn is_ok_and(self, f: impl FnOnce(T) -> bool) -> bool { - match self { - Ok(v) => f(v), - Err(_) => false, - } - } - fn is_err_and(self, f: impl FnOnce(E) -> bool) -> bool { - match self { - Ok(_) => false, - Err(e) => f(e), - } - } -} - pub trait IsSorted { type T; fn is_sorted_by(&self, pred: impl Fn(&Self::T, &Self::T) -> Option) diff --git a/src/reader.rs b/src/reader.rs index 0acf0cc4b..e3cfb6829 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -60,7 +60,7 @@ use crate::fds::{make_fd_blocking, wopen_cloexec, AutoCloseFd}; use crate::flog::{FLOG, FLOGF}; #[allow(unused_imports)] -use crate::future::{IsOkAnd, IsSomeAnd}; +use crate::future::IsSomeAnd; use crate::global_safety::RelaxedAtomicBool; use crate::highlight::{ autosuggest_validate_from_history, highlight_shell, HighlightRole, HighlightSpec,