Use array's IntoIterator impl and nested or patterns

*yay*
This commit is contained in:
Laurenz 2021-07-16 12:03:00 +02:00
parent 81f2f8f4c3
commit 5edbd3a5b5
4 changed files with 5 additions and 8 deletions

View File

@ -227,12 +227,12 @@ impl Constraints {
/// Changes all constraints by adding the `size` to them if they are `Some`. /// Changes all constraints by adding the `size` to them if they are `Some`.
pub fn mutate(&mut self, size: Size, regions: &Regions) { pub fn mutate(&mut self, size: Size, regions: &Regions) {
for spec in std::array::IntoIter::new([ for spec in [
&mut self.min, &mut self.min,
&mut self.max, &mut self.max,
&mut self.exact, &mut self.exact,
&mut self.base, &mut self.base,
]) { ] {
if let Some(horizontal) = spec.horizontal.as_mut() { if let Some(horizontal) = spec.horizontal.as_mut() {
*horizontal += size.width; *horizontal += size.width;
} }

View File

@ -249,7 +249,7 @@ fn expr_with(p: &mut Parser, atomic: bool, min_prec: usize) -> Option<Expr> {
// call. // call.
if matches!( if matches!(
p.peek_direct(), p.peek_direct(),
Some(Token::Excl) | Some(Token::LeftParen) | Some(Token::LeftBracket), Some(Token::Excl | Token::LeftParen | Token::LeftBracket),
) { ) {
lhs = call(p, lhs)?; lhs = call(p, lhs)?;
continue; continue;

View File

@ -381,10 +381,7 @@ impl<'s> Parser<'s> {
/// Whether the active group ends at a newline. /// Whether the active group ends at a newline.
fn stop_at_newline(&self) -> bool { fn stop_at_newline(&self) -> bool {
let active = self.groups.last().map(|group| group.kind); let active = self.groups.last().map(|group| group.kind);
matches!( matches!(active, Some(Group::Stmt | Group::Expr | Group::Imports))
active,
Some(Group::Stmt) | Some(Group::Expr) | Some(Group::Imports)
)
} }
/// Whether we are inside the given group. /// Whether we are inside the given group.

View File

@ -898,7 +898,7 @@ mod tests {
t!(Code[" /"]: large.to_string() => Float(large)); t!(Code[" /"]: large.to_string() => Float(large));
// Combined integers and floats. // Combined integers and floats.
let nums = ints.iter().map(|&(k, v)| (k, v as f64)).chain(floats.iter().copied()); let nums = ints.iter().map(|&(k, v)| (k, v as f64)).chain(floats);
let suffixes = [ let suffixes = [
("%", Percent as fn(f64) -> Token<'static>), ("%", Percent as fn(f64) -> Token<'static>),