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?
This commit is contained in:
Fabian Boehm 2024-04-28 15:51:46 +02:00
parent 16fcc5de7c
commit 4d4ef7fa40
4 changed files with 2 additions and 36 deletions

View file

@ -30,7 +30,7 @@ use fish::expand::INTERNAL_SEPARATOR;
use fish::fds::set_cloexec; use fish::fds::set_cloexec;
use fish::fprintf; use fish::fprintf;
#[allow(unused_imports)] #[allow(unused_imports)]
use fish::future::{IsOkAnd, IsSomeAnd, IsSorted}; use fish::future::{IsSomeAnd, IsSorted};
use fish::global_safety::RelaxedAtomicBool; use fish::global_safety::RelaxedAtomicBool;
use fish::highlight::{colorize, highlight_shell, HighlightRole, HighlightSpec}; use fish::highlight::{colorize, highlight_shell, HighlightRole, HighlightSpec};
use fish::libc::setlinebuf; use fish::libc::setlinebuf;

View file

@ -7,7 +7,6 @@ mod test_expressions {
use super::*; use super::*;
#[allow(unused_imports)] #[allow(unused_imports)]
use crate::future::IsOkAnd;
use crate::nix::isatty; use crate::nix::isatty;
use crate::wutil::{ use crate::wutil::{
file_id_for_path, fish_wcswidth, lwstat, waccess, wcstod::wcstod, wcstoi_opts, wstat, file_id_for_path, fish_wcswidth, lwstat, waccess, wcstod::wcstod, wcstoi_opts, wstat,

View file

@ -3,18 +3,10 @@
pub trait IsSomeAnd { pub trait IsSomeAnd {
type Type; type Type;
#[allow(clippy::wrong_self_convention)] #[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; fn is_none_or(self, s: impl FnOnce(Self::Type) -> bool) -> bool;
} }
impl<T> IsSomeAnd for Option<T> { impl<T> IsSomeAnd for Option<T> {
type Type = T; 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 { fn is_none_or(self, f: impl FnOnce(T) -> bool) -> bool {
match self { match self {
Some(v) => f(v), Some(v) => f(v),
@ -23,31 +15,6 @@ impl<T> IsSomeAnd for Option<T> {
} }
} }
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<T, E> IsOkAnd for Result<T, E> {
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 { pub trait IsSorted {
type T; type T;
fn is_sorted_by(&self, pred: impl Fn(&Self::T, &Self::T) -> Option<std::cmp::Ordering>) fn is_sorted_by(&self, pred: impl Fn(&Self::T, &Self::T) -> Option<std::cmp::Ordering>)

View file

@ -60,7 +60,7 @@ use crate::fd_readable_set::poll_fd_readable;
use crate::fds::{make_fd_blocking, wopen_cloexec, AutoCloseFd}; use crate::fds::{make_fd_blocking, wopen_cloexec, AutoCloseFd};
use crate::flog::{FLOG, FLOGF}; use crate::flog::{FLOG, FLOGF};
#[allow(unused_imports)] #[allow(unused_imports)]
use crate::future::{IsOkAnd, IsSomeAnd}; use crate::future::IsSomeAnd;
use crate::global_safety::RelaxedAtomicBool; use crate::global_safety::RelaxedAtomicBool;
use crate::highlight::{ use crate::highlight::{
autosuggest_validate_from_history, highlight_shell, HighlightRole, HighlightSpec, autosuggest_validate_from_history, highlight_shell, HighlightRole, HighlightSpec,