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::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;

View File

@ -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,

View File

@ -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<T> IsSomeAnd for Option<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 {
match self {
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 {
type T;
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::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,