1
Fork 0

Adopt let else in more places

This commit is contained in:
est31 2022-02-19 00:48:49 +01:00
parent b8c56fa8c3
commit 2ef8af6619
132 changed files with 539 additions and 881 deletions

View file

@ -10,9 +10,8 @@ pub fn binary_search_slice<'d, E, K>(data: &'d [E], key_fn: impl Fn(&E) -> K, ke
where
K: Ord,
{
let mid = match data.binary_search_by_key(key, &key_fn) {
Ok(mid) => mid,
Err(_) => return &[],
let Ok(mid) = data.binary_search_by_key(key, &key_fn) else {
return &[];
};
let size = data.len();

View file

@ -14,6 +14,7 @@
#![feature(control_flow_enum)]
#![feature(core_intrinsics)]
#![feature(extend_one)]
#![feature(let_else)]
#![feature(hash_raw_entry)]
#![feature(maybe_uninit_uninit_array)]
#![feature(min_specialization)]

View file

@ -190,11 +190,8 @@ impl<T: Eq + Hash> TransitiveRelation<T> {
///
/// Note that this set can, in principle, have any size.
pub fn minimal_upper_bounds(&self, a: &T, b: &T) -> Vec<&T> {
let (mut a, mut b) = match (self.index(a), self.index(b)) {
(Some(a), Some(b)) => (a, b),
(None, _) | (_, None) => {
return vec![];
}
let (Some(mut a), Some(mut b)) = (self.index(a), self.index(b)) else {
return vec![];
};
// in some cases, there are some arbitrary choices to be made;
@ -294,9 +291,8 @@ impl<T: Eq + Hash> TransitiveRelation<T> {
/// then `parents(a)` returns `[b, c]`. The `postdom_parent` function
/// would further reduce this to just `f`.
pub fn parents(&self, a: &T) -> Vec<&T> {
let a = match self.index(a) {
Some(a) => a,
None => return vec![],
let Some(a) = self.index(a) else {
return vec![];
};
// Steal the algorithm for `minimal_upper_bounds` above, but