From 4d4ef7fa409620825f3548d9f3e1efec16e545a4 Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Sun, 28 Apr 2024 15:51:46 +0200 Subject: [PATCH] Remove backports for 1.67 This removes IsOkAnd and the is_some_and method. I cannot actually find is_none_or in the stdlib? I've kept the trait name to avoid changing it now and then later, maybe this should be moved elsewhere to avoid claiming it's an stdlib thing? --- src/bin/fish_indent.rs | 2 +- src/builtins/test.rs | 1 - src/future.rs | 33 --------------------------------- src/reader.rs | 2 +- 4 files changed, 2 insertions(+), 36 deletions(-) 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::expand::INTERNAL_SEPARATOR; 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 @@ impl IsSomeAnd for Option { } } -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::fd_readable_set::poll_fd_readable; 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,