Skip to content

Commit

Permalink
Rust 1.81.0
Browse files Browse the repository at this point in the history
  • Loading branch information
fornwall committed Sep 9, 2024
1 parent b439182 commit 5c758b7
Show file tree
Hide file tree
Showing 14 changed files with 17 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ edition = "2021"
homepage = "https://github.com/fornwall/advent-of-code"
license = "MIT"
repository = "https://github.com/fornwall/advent-of-code"
rust-version = "1.80.1"
rust-version = "1.81.0"
version = "2022.0.66"

[profile.release]
Expand Down
4 changes: 2 additions & 2 deletions crates/core/src/common/int_to_ascii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ impl IntToAsciiContext {
#[test]
fn to_ascii() {
let mut context = IntToAsciiContext::new();
assert_eq!(context.ascii_bytes(1), &[b'1']);
assert_eq!(context.ascii_bytes(0), &[b'0']);
assert_eq!(context.ascii_bytes(1), b"1");
assert_eq!(context.ascii_bytes(0), b"0");
assert_eq!(context.ascii_bytes(134), b"134");
assert_eq!(context.ascii_bytes(4_294_967_295), b"4294967295");
}
3 changes: 2 additions & 1 deletion crates/core/src/common/md5.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ fn transform(state: &mut [u32; 4], input: &[u32; 16]) {
($a:expr, $b:expr) => ($a.wrapping_add($b));
);
macro_rules! rotate(
($x:expr, $n:expr) => (($x << $n) | ($x >> (32 - $n)));
//($x:expr, $n:expr) => (($x << $n) | ($x >> (32 - $n)));
($x:expr, $n:expr) => ($x.rotate_left($n));
);
{
macro_rules! F(
Expand Down
5 changes: 2 additions & 3 deletions crates/core/src/year2018/day07.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,11 @@ fn parse_input(input_string: &str) -> Result<ParsedInput, String> {
let step_name = parts[7]
.chars()
.next()
.ok_or(format!("Invalid line: {line_number}"))?;
.ok_or_else(|| format!("Invalid line: {line_number}"))?;
let depends_on = parts[1]
.chars()
.next()
.ok_or(format!("Invalid line: {line_number}"))?;

.ok_or_else(|| format!("Invalid line: {line_number}"))?;
let step = step_map
.entry(step_name)
.or_insert_with(|| Step::new(step_name));
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/year2018/day10.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub fn solve(input: &Input) -> Result<String, String> {
.map(|(line_index, line)| {
let error = || format!("Invalid input at line {}", line_index + 1);

let parts: Vec<&str> = line.split(|c| c == '<' || c == '>' || c == ',').collect();
let parts: Vec<&str> = line.split(['<', '>', ',']).collect();
if parts.len() < 6 || !line.starts_with("position=") {
return Err(error());
}
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/year2018/day16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl ProblemInput {
let after = line.starts_with("After:");
if before || after {
let parts: Vec<u16> = line[9..]
.split(|c| c == '[' || c == ']' || c == ',')
.split(['[', ']', ','])
.filter_map(|s| {
if s.is_empty() {
None
Expand Down
4 changes: 1 addition & 3 deletions crates/core/src/year2018/day23.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,7 @@ impl Nanobot {
.enumerate()
.map(|(line_index, line)| {
let line_number = line_index + 1;
let parts: Vec<&str> = line
.split(|c| c == '<' || c == '>' || c == ',' || c == '=')
.collect();
let parts: Vec<&str> = line.split(['<', '>', ',', '=']).collect();
let error_message = || format!("Invalid input on line {line_number}");
if parts.len() != 8 {
return Err(error_message());
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/year2018/day24.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl ArmyGroup {
} else {
// "17 units each with 5390 hit points (weak to radiation, bludgeoning) with
// an attack that does 4507 fire damage at initiative 2".
let main_parts: Vec<&str> = line.split(|c| c == '(' || c == ')').collect();
let main_parts: Vec<&str> = line.split(['(', ')']).collect();

let mut weaknesses = Vec::new();
let mut immunities = Vec::new();
Expand Down
4 changes: 1 addition & 3 deletions crates/core/src/year2019/day12.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ impl Moons {
let mut positions = [[0; 3]; 4];
for (i, line) in input.lines().enumerate() {
let error_message = |_| format!("Invalid line: {}", i + 1);
let parts: Vec<&str> = line
.split(|c| c == '=' || c == ' ' || c == '>' || c == ',')
.collect();
let parts: Vec<&str> = line.split(['=', ' ', '>', ',']).collect();

if parts.len() != 9 {
return Err(format!("Invalid line: {}", i + 1));
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/year2019/day22.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub fn solve(input: &Input) -> Result<i128, String> {
deck.iter()
.position(|&card| card == 2019)
.map(|p| p as i128)
.ok_or(format!("No card {desired_card} found"))
.ok_or_else(|| format!("No card {desired_card} found"))
} else {
/// Explanation:
/// <https://www.reddit.com/r/adventofcode/comments/ee0rqi/2019_day_22_solutions/fbnkaju?utm_source=share&utm_medium=web2x/>
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/year2021/day20.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct Image {
}

impl Image {
fn new(pixels: Vec<bool>) -> Self {
const fn new(pixels: Vec<bool>) -> Self {
Self { pixels }
}

Expand Down
1 change: 1 addition & 0 deletions crates/grpc-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use advent::{ProblemInput, ProblemOutput};

mod advent {
#![allow(warnings)]
#![allow(clippy::derive_partial_eq_without_eq)]
#![allow(clippy::future_not_send)]
#![allow(clippy::missing_const_for_fn)]
#![allow(clippy::similar_names)]
Expand Down
2 changes: 1 addition & 1 deletion crates/svgplot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ impl SvgImage {
.unwrap();
}
self.common_attributes.write(&mut buffer);
buffer.write_all(&[b'>', b'\n']).unwrap();
buffer.write_all(b">\n").unwrap();

let mut first = true;
for (id, element) in &self.elements {
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "1.80.1"
channel = "1.81.0"
components = ["rustfmt", "clippy"]
targets = ["wasm32-unknown-unknown"]

1 comment on commit 5c758b7

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@                     Benchmark Difference                     @@
#      Name   Old (instructions)   New (instructions)   Change (%)
   2023_1_1            1,470,575            1,476,330            0
   2023_1_2            1,443,157            1,448,912            0
   2023_2_1              626,011              624,095            0
   2023_2_2              600,829              598,020            0
   2023_3_1              824,431              829,014            0
   2023_3_2              620,997              624,423            0
   2023_4_1              906,572              928,057           +2
   2023_4_2              917,788              939,273           +2
   2023_5_1              620,547              626,868           +1
   2023_5_2              741,396              747,717            0
   2023_6_1                3,585                3,615            0
   2023_6_2                2,580                2,610           +1
   2023_7_1              657,015              647,846           -1
   2023_7_2              648,985              644,017            0
   2023_8_1            1,180,443            1,184,545            0
   2023_8_2            2,585,707            2,589,677            0
   2023_9_1              795,805              795,741            0
   2023_9_2              807,532              807,468            0
  2023_10_1            2,859,049            3,079,160           +7
  2023_10_2            3,429,523            3,649,635           +6
  2023_11_1            2,748,161            2,751,819            0
  2023_11_2            2,748,185            2,751,843            0
  2023_12_1            4,295,517            4,361,571           +1
  2023_12_2           68,303,611           69,325,853           +1
  2023_13_1              567,529              567,237            0
  2023_13_2              568,537              568,245            0
  2023_14_1              836,969              838,038            0
  2023_14_2          290,236,867          290,237,929            0
  2023_15_1              762,587              780,731           +2
  2023_15_2            1,045,167            1,063,311           +1
  2023_16_1            1,057,143            1,066,736            0
  2023_16_2          216,038,022          218,396,595           +1
  2023_17_1          219,432,127          219,779,803            0
  2023_17_2          666,688,145          667,612,992            0
  2023_18_1              343,180              354,014           +3
  2023_18_2              414,790              425,624           +2
  2023_19_1            2,852,868            2,884,876           +1
  2023_19_2            1,789,721            1,805,296            0
  2023_20_1            4,549,034            4,583,156            0
  2023_20_2           17,783,195           17,923,230            0
  2023_21_1           83,478,827           90,599,962           +8
  2023_21_2            7,500,122            7,502,030            0
  2023_22_1           10,665,156           10,701,107            0
  2023_22_2          291,755,214          291,719,425            0
  2023_23_1            1,679,623            1,628,388           -3
  2023_23_2        1,129,484,962        1,129,401,089            0
  2023_24_1           16,191,357           16,178,529            0
  2023_24_2            1,186,595            1,173,774           -1
  2023_25_1            4,710,493            4,726,396            0
Benchmark Instructions (count) Instructions (%)
2023_23_2 1,129,401,089 36.6
2023_17_2 667,612,992 21.6
2023_22_2 291,719,425 9.5
2023_14_2 290,237,929 9.4
2023_17_1 219,779,803 7.1
2023_16_2 218,396,595 7.1
2023_21_1 90,599,962 2.9
2023_12_2 69,325,853 2.2
2023_20_2 17,923,230 0.6
2023_24_1 16,178,529 0.5
2023_22_1 10,701,107 0.3
2023_21_2 7,502,030 0.2
2023_25_1 4,726,396 0.2
2023_20_1 4,583,156 0.1
2023_12_1 4,361,571 0.1
2023_10_2 3,649,635 0.1
2023_10_1 3,079,160 0.1
2023_19_1 2,884,876 0.1
2023_11_2 2,751,843 0.1
2023_11_1 2,751,819 0.1
2023_8_2 2,589,677 0.1
2023_19_2 1,805,296 0.1
2023_23_1 1,628,388 0.1
2023_1_1 1,476,330 0.0
2023_1_2 1,448,912 0.0
2023_8_1 1,184,545 0.0
2023_24_2 1,173,774 0.0
2023_16_1 1,066,736 0.0
2023_15_2 1,063,311 0.0
2023_4_2 939,273 0.0
2023_4_1 928,057 0.0
2023_14_1 838,038 0.0
2023_3_1 829,014 0.0
2023_9_2 807,468 0.0
2023_9_1 795,741 0.0
2023_15_1 780,731 0.0
2023_5_2 747,717 0.0
2023_7_1 647,846 0.0
2023_7_2 644,017 0.0
2023_5_1 626,868 0.0
2023_3_2 624,423 0.0
2023_2_1 624,095 0.0
2023_2_2 598,020 0.0
2023_13_2 568,245 0.0
2023_13_1 567,237 0.0
2023_18_2 425,624 0.0
2023_18_1 354,014 0.0
2023_6_1 3,615 0.0
2023_6_2 2,610 0.0

Please sign in to comment.