Skip to content

Commit 5c37019

Browse files
committed
Bump Rust version to 1.83
1 parent fa3cb11 commit 5c37019

File tree

7 files changed

+35
-31
lines changed

7 files changed

+35
-31
lines changed

Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "aoc"
33
version = "2024.12.25"
44
edition = "2021"
5-
rust-version = "1.82"
5+
rust-version = "1.83"
66

77
[features]
88
frivolity = []
@@ -194,6 +194,7 @@ needless_raw_strings = "warn"
194194
no_effect_underscore_binding = "warn"
195195
no_mangle_with_rust_abi = "warn"
196196
non_ascii_literal = "allow"
197+
non_zero_suggestions = "warn"
197198
option_as_ref_cloned = "warn"
198199
option_option = "warn"
199200
panic = "allow"
@@ -219,7 +220,7 @@ redundant_else = "warn"
219220
redundant_type_annotations = "warn"
220221
ref_as_ptr = "warn"
221222
ref_binding_to_reference = "warn"
222-
ref_option_ref = "warn"
223+
ref_option = "warn"
223224
ref_patterns = "warn"
224225
renamed_function_params = "warn"
225226
rest_pat_in_fully_bound_structs = "warn"
@@ -279,6 +280,7 @@ unseparated_literal_suffix = "warn"
279280
unused_async = "warn"
280281
unused_result_ok = "warn"
281282
unused_self = "warn"
283+
unused_trait_names = "warn"
282284
unwrap_in_result = "allow"
283285
unwrap_used = "allow"
284286
use_debug = "warn"

src/util/hash.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//! resistant but slower hashing algorithm. [`FxHasher`] is much faster (between 2x to 5x from my testing).
77
use std::collections::{HashMap, HashSet};
88
use std::hash::{BuildHasher, Hash, Hasher};
9-
use std::ops::BitXor;
9+
use std::ops::BitXor as _;
1010

1111
/// Type alias for [`HashSet`] using [`FxHasher`].
1212
pub type FastSet<T> = HashSet<T, BuildFxHasher>;

src/year2017/day10.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//! [`rotate_left`]: slice::rotate_left
88
//! [`reverse`]: slice::reverse
99
use crate::util::parse::*;
10-
use std::fmt::Write;
10+
use std::fmt::Write as _;
1111

1212
pub fn parse(input: &str) -> &str {
1313
input

src/year2019/day13.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ pub fn part2(input: &[i64]) -> i64 {
9292
#[cfg(feature = "frivolity")]
9393
fn draw(tiles: &[i64], score: i64, blocks: i64) {
9494
use crate::util::ansi::*;
95-
use std::fmt::Write;
95+
use std::fmt::Write as _;
9696
use std::thread::sleep;
9797
use std::time::Duration;
9898

src/year2019/day17.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use super::intcode::*;
1818
use crate::util::hash::*;
1919
use crate::util::parse::*;
2020
use crate::util::point::*;
21-
use std::fmt::Write;
21+
use std::fmt::Write as _;
2222
use std::ops::ControlFlow;
2323

2424
pub struct Input {

src/year2019/day25.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
use super::intcode::*;
2020
use crate::util::hash::*;
2121
use crate::util::parse::*;
22-
use std::fmt::Write;
22+
use std::fmt::Write as _;
2323

2424
pub fn parse(input: &str) -> Vec<i64> {
2525
input.iter_signed().collect()

src/year2024/day09.rs

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,39 +29,40 @@ pub fn parse(input: &str) -> Vec<usize> {
2929
/// Block by block checksum comparison that doesn't allocate any memory.
3030
pub fn part1(disk: &[usize]) -> usize {
3131
// Start at the first free block and the last file.
32-
let mut free = 0;
33-
let mut file = disk.len() + disk.len() % 2;
32+
let mut left = 0;
33+
let mut right = disk.len() + disk.len() % 2;
3434

35-
let mut available = 0;
35+
let mut available;
3636
let mut needed = 0;
3737

3838
let mut block = 0;
3939
let mut checksum = 0;
4040

41-
while free < file {
42-
// Take as much space as possible from the current free block range.
43-
let size = needed.min(available);
44-
(checksum, block) = update(checksum, block, file, size);
45-
available -= size;
46-
needed -= size;
47-
48-
// One or both of "available" and "free" could be zero.
49-
if needed == 0 {
50-
file -= 2;
51-
needed = disk[file];
52-
}
53-
41+
while left < right {
5442
// When moving to the next free block, add the checksum for the file we're skipping over.
55-
if available == 0 {
56-
let size = disk[free];
57-
(checksum, block) = update(checksum, block, free, size);
58-
available = disk[free + 1];
59-
free += 2;
43+
(checksum, block) = update(checksum, block, left, disk[left]);
44+
available = disk[left + 1];
45+
left += 2;
46+
47+
while available > 0 {
48+
if needed == 0 {
49+
if right == left {
50+
break;
51+
}
52+
right -= 2;
53+
needed = disk[right];
54+
}
55+
56+
// Take as much space as possible from the current free block range.
57+
let size = needed.min(available);
58+
(checksum, block) = update(checksum, block, right, size);
59+
available -= size;
60+
needed -= size;
6061
}
6162
}
6263

6364
// Account for any remaining file blocks left over.
64-
(checksum, _) = update(checksum, block, file, needed);
65+
(checksum, _) = update(checksum, block, right, needed);
6566
checksum
6667
}
6768

@@ -92,8 +93,9 @@ pub fn part2(disk: &[usize]) -> usize {
9293
let mut next_block = block;
9394
let mut next_index = usize::MAX;
9495

95-
for (i, heap) in free.iter().enumerate().skip(size) {
96-
if let Some((&first, ())) = heap.peek() {
96+
#[allow(clippy::needless_range_loop)]
97+
for i in size..free.len() {
98+
if let Some((&first, ())) = free[i].peek() {
9799
if first < next_block {
98100
next_block = first;
99101
next_index = i;

0 commit comments

Comments
 (0)