cargo fmt

This commit is contained in:
Xiretza 2023-12-18 18:19:29 +00:00
parent 3e9c1ee1c1
commit ed41d840f5
5 changed files with 20 additions and 11 deletions

View file

@ -7,7 +7,9 @@ use std::{
use nom::{ use nom::{
bits::complete as bits, bits::complete as bits,
multi::{many0, many_m_n}, error::ParseError, Offset, error::ParseError,
multi::{many0, many_m_n},
Offset,
}; };
use nom::{combinator::map, sequence::pair}; use nom::{combinator::map, sequence::pair};
use parsers::fold_till; use parsers::fold_till;
@ -68,7 +70,9 @@ impl PacketType {
} }
} }
fn parse_sub_packets<'a, E: ParseError<Input<'a>>>(i: Input<'a>) -> IResult<'a, Vec<Packet>, E> { fn parse_sub_packets<'a, E: ParseError<Input<'a>>>(
i: Input<'a>,
) -> IResult<'a, Vec<Packet>, E> {
enum LengthType { enum LengthType {
Bits(usize), Bits(usize),
Packets(usize), Packets(usize),
@ -102,10 +106,7 @@ impl PacketType {
assert_eq!(i.0.offset(subpackets_end.0), i.0.offset(new_input.0)); assert_eq!(i.0.offset(subpackets_end.0), i.0.offset(new_input.0));
assert_eq!(subpackets_end.1, new_input.1); assert_eq!(subpackets_end.1, new_input.1);
Ok(( Ok((new_input, subpackets))
new_input,
subpackets,
))
} }
} }
} }
@ -199,7 +200,9 @@ fn main() {
.flatten() .flatten()
.collect(); .collect();
let packet = Packet::parse::<nom::error::Error<_>>((&bytes, 0)).unwrap().1; let packet = Packet::parse::<nom::error::Error<_>>((&bytes, 0))
.unwrap()
.1;
println!("{}", packet.version_sum()); println!("{}", packet.version_sum());
println!("{}", packet.typ.evaluate()); println!("{}", packet.typ.evaluate());
} }

View file

@ -52,7 +52,7 @@ pub fn unscramble(line: &str) -> LineResult {
} }
Some(c @ b'a'..=b'g') => { Some(c @ b'a'..=b'g') => {
freq += counts[c as usize - b'a' as usize]; freq += counts[c as usize - b'a' as usize];
}, }
Some(_) => {} Some(_) => {}
} }
} }

View file

@ -30,7 +30,11 @@ fn main() {
.strip_prefix(b"[") .strip_prefix(b"[")
.and_then(|crate_| crate_.strip_suffix(b"]")) .and_then(|crate_| crate_.strip_suffix(b"]"))
else { else {
panic!("invalid crate {:?} {}", crate_, std::str::from_utf8(crate_).unwrap()); panic!(
"invalid crate {:?} {}",
crate_,
std::str::from_utf8(crate_).unwrap()
);
}; };
Some(*crate_ as char) Some(*crate_ as char)

View file

@ -1,9 +1,9 @@
#![warn(clippy::pedantic)] #![warn(clippy::pedantic)]
pub mod grid;
mod section_range; mod section_range;
pub mod vec2; pub mod vec2;
pub mod vecn; pub mod vecn;
pub mod grid;
use std::{mem, path::Path}; use std::{mem, path::Path};

View file

@ -222,7 +222,9 @@ impl Iterator for LinePoints {
type Item = Vec2; type Item = Vec2;
fn next(&mut self) -> Option<Self::Item> { fn next(&mut self) -> Option<Self::Item> {
let Some(line) = self.line.as_mut() else { return None }; let Some(line) = self.line.as_mut() else {
return None;
};
let delta = (line.end - line.start).map(i32::signum); let delta = (line.end - line.start).map(i32::signum);