Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 58bfd5a

Browse files
Bump Rust version to 1.84
1 parent bf8c14a commit 58bfd5a

File tree

13 files changed

+30
-52
lines changed

13 files changed

+30
-52
lines changed

‎.github/workflows/checks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
runs-on: ubuntu-latest
2121
steps:
2222
- uses: actions/checkout@v4
23-
- run: rustup default 1.83
23+
- run: rustup default 1.84
2424
- run: cargo test
2525

2626
test-nightly:

‎.github/workflows/docs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
url: ${{ steps.deployment.outputs.page_url }}
1919
steps:
2020
- uses: actions/checkout@v4
21+
- run: rustup default 1.84
2122
- run: cargo doc
2223
env:
2324
RUSTDOCFLAGS: "--document-private-items --default-theme=ayu --deny warnings"

‎Cargo.toml

Lines changed: 6 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.83"
5+
rust-version = "1.84"
66

77
[features]
88
frivolity = []
@@ -54,6 +54,7 @@ absolute_paths = "warn"
5454
alloc_instead_of_core = "warn"
5555
allow_attributes = "allow"
5656
allow_attributes_without_reason = "allow"
57+
arbitrary_source_item_ordering = "allow"
5758
arithmetic_side_effects = "allow"
5859
as_conversions = "allow"
5960
as_underscore = "warn"
@@ -151,13 +152,15 @@ macro_use_imports = "warn"
151152
manual_assert = "warn"
152153
manual_c_str_literals = "warn"
153154
manual_instant_elapsed = "warn"
155+
manual_is_power_of_two = "warn"
154156
manual_is_variant_and = "warn"
155157
manual_let_else = "warn"
156158
manual_ok_or = "warn"
157159
manual_string_new = "warn"
158160
many_single_char_names = "allow"
159161
map_err_ignore = "warn"
160162
map_unwrap_or = "warn"
163+
map_with_unused_argument_over_ranges = "warn"
161164
match_bool = "warn"
162165
match_on_vec_items = "allow"
163166
match_same_arms = "warn"
@@ -267,6 +270,7 @@ unimplemented = "warn"
267270
uninlined_format_args = "warn"
268271
unnecessary_box_returns = "warn"
269272
unnecessary_join = "warn"
273+
unnecessary_literal_bound = "warn"
270274
unnecessary_safety_comment = "warn"
271275
unnecessary_safety_doc = "warn"
272276
unnecessary_self_imports = "warn"
@@ -284,7 +288,7 @@ unused_trait_names = "warn"
284288
unwrap_in_result = "allow"
285289
unwrap_used = "allow"
286290
use_debug = "warn"
287-
used_underscore_binding = "warn"
291+
used_underscore_items = "warn"
288292
verbose_bit_mask = "warn"
289293
verbose_file_reads = "warn"
290294
wildcard_enum_match_arm = "allow"

‎README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ Performance is reasonable even on older hardware, for example a 2011 MacBook Pro
283283
| 19 | [Go With The Flow](https://adventofcode.com/2018/day/19) | [Source](src/year2018/day19.rs) | 1 |
284284
| 20 | [A Regular Map](https://adventofcode.com/2018/day/20) | [Source](src/year2018/day20.rs) | 36 |
285285
| 21 | [Chronal Conversion](https://adventofcode.com/2018/day/21) | [Source](src/year2018/day21.rs) | 66 |
286-
| 22 | [Mode Maze](https://adventofcode.com/2018/day/22) | [Source](src/year2018/day22.rs) | 3396 |
286+
| 22 | [Mode Maze](https://adventofcode.com/2018/day/22) | [Source](src/year2018/day22.rs) | 3197 |
287287
| 23 | [Experimental Emergency Teleportation](https://adventofcode.com/2018/day/23) | [Source](src/year2018/day23.rs) | 506 |
288288
| 24 | [Immune System Simulator 20XX](https://adventofcode.com/2018/day/24) | [Source](src/year2018/day24.rs) | 2056 |
289289
| 25 | [Four-Dimensional Adventure](https://adventofcode.com/2018/day/25) | [Source](src/year2018/day25.rs) | 323 |
@@ -316,7 +316,7 @@ Performance is reasonable even on older hardware, for example a 2011 MacBook Pro
316316
| 20 | [Particle Swarm](https://adventofcode.com/2017/day/20) | [Source](src/year2017/day20.rs) | 245 |
317317
| 21 | [Fractal Art](https://adventofcode.com/2017/day/21) | [Source](src/year2017/day21.rs) | 5 |
318318
| 22 | [Sporifica Virus](https://adventofcode.com/2017/day/22) | [Source](src/year2017/day22.rs) | 36000 |
319-
| 23 | [Coprocessor Conflagration](https://adventofcode.com/2017/day/23) | [Source](src/year2017/day23.rs) | 55 |
319+
| 23 | [Coprocessor Conflagration](https://adventofcode.com/2017/day/23) | [Source](src/year2017/day23.rs) | 54 |
320320
| 24 | [Electromagnetic Moat](https://adventofcode.com/2017/day/24) | [Source](src/year2017/day24.rs) | 275 |
321321
| 25 | [The Halting Problem](https://adventofcode.com/2017/day/25) | [Source](src/year2017/day25.rs) | 3698 |
322322

‎src/util/integer.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ pub trait Integer<T>:
2222
const ONE: T;
2323
const TEN: T;
2424

25-
fn ilog2(self) -> T;
2625
fn trailing_zeros(self) -> T;
2726
}
2827

@@ -37,12 +36,6 @@ macro_rules! integer {
3736
const ONE: $t = 1;
3837
const TEN: $t = 10;
3938

40-
#[inline]
41-
#[allow(trivial_numeric_casts)]
42-
fn ilog2(self) -> $t {
43-
<$t>::ilog2(self) as $t
44-
}
45-
4639
#[inline]
4740
#[allow(trivial_numeric_casts)]
4841
fn trailing_zeros(self) -> $t {

‎src/util/math.rs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ pub trait IntegerMathOps<T: Integer<T>> {
2222
fn mod_pow(self, e: T, m: T) -> T;
2323
}
2424

25-
pub trait UnsignedMathOps<T: Unsigned<T>> {
26-
fn sqrt(self) -> T;
27-
}
28-
2925
pub trait SignedMathOps<T: Signed<T>> {
3026
fn mod_inv(self, m: T) -> Option<T>;
3127
}
@@ -64,24 +60,6 @@ impl<T: Integer<T>> IntegerMathOps<T> for T {
6460
}
6561
}
6662

67-
impl<T: Unsigned<T>> UnsignedMathOps<T> for T {
68-
// Integer square root. Once [`isqrt`] is stablized then this function can be removed.
69-
fn sqrt(self) -> T {
70-
let mut bit = T::ONE << (self.ilog2() >> T::ONE);
71-
let mut root = bit;
72-
73-
while bit > T::ONE {
74-
bit = bit >> T::ONE;
75-
let next = root | bit;
76-
if next * next <= self {
77-
root = next;
78-
}
79-
}
80-
81-
root
82-
}
83-
}
84-
8563
impl<T: Signed<T>> SignedMathOps<T> for T {
8664
// Modular multiplicative inverse
8765
fn mod_inv(self, m: T) -> Option<T> {

‎src/year2017/day23.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@
4949
//! this directly would take at least 105.105.103 = 1013 = 10,000,000,000,000 steps.
5050
//!
5151
//! [`Day 18`]: crate::year2017::day18
52-
53-
use crate::util::math::*;
5452
use crate::util::parse::*;
5553

5654
/// We only need the vrey first number from the input.
@@ -71,7 +69,7 @@ pub fn part2(input: &u32) -> usize {
7169
/// Simple [prime number check](https://en.wikipedia.org/wiki/Primality_test)
7270
/// of all factors from 2 to √n inclusive.
7371
fn composite(n: u32) -> Option<u32> {
74-
for f in 2..=n.sqrt() {
72+
for f in 2..=n.isqrt() {
7573
if n % f == 0 {
7674
return Some(n);
7775
}

‎src/year2018/day22.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ use crate::util::grid::*;
2727
use crate::util::iter::*;
2828
use crate::util::parse::*;
2929
use crate::util::point::*;
30+
use std::iter::repeat_with;
3031

3132
/// The index of each tool is that tool that *cannot* be used in that region, for example
3233
/// Rocky => 0 => Neither, Wet => 1 => Torch and Narrow => 2 => Climbing Gear.
@@ -72,7 +73,7 @@ pub fn part2(input: &Input) -> i32 {
7273

7374
// Initialise bucket queue with pre-allocated capacity to reduce reallocations needed.
7475
let mut base = 0;
75-
let mut todo = (0..BUCKETS).map(|_| Vec::with_capacity(1000)).collect::<Vec<_>>();
76+
let mut todo = repeat_with(|| Vec::with_capacity(1000)).take(BUCKETS).collect::<Vec<_>>();
7677

7778
// Add extra width and height so the search does not exceed the bounds of the grid.
7879
let mut cave = scan_cave(input, width + 10, height + 140);

‎src/year2019/day14.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use crate::util::hash::*;
66
use crate::util::iter::*;
77
use crate::util::parse::*;
88
use std::cmp::Ordering;
9+
use std::iter::repeat_with;
910

1011
struct Ingredient {
1112
amount: u64,
@@ -23,15 +24,15 @@ pub struct Reaction {
2324
pub fn parse(input: &str) -> Vec<Reaction> {
2425
let lines: Vec<_> = input.lines().collect();
2526

26-
let mut reactions: Vec<_> = (0..lines.len() + 1)
27-
.map(|_| {
28-
Reaction{
29-
amount:0,
30-
chemical:1,// Default to ORE, other chemicals will overwrite.
31-
ingredients:Vec::new(),
32-
}
33-
})
34-
.collect();
27+
let mut reactions: Vec<_> = repeat_with(|| {
28+
Reaction {
29+
amount:0,
30+
chemical:1,// Default to ORE, other chemicals will overwrite.
31+
ingredients:Vec::new(),
32+
}
33+
})
34+
.take(lines.len() + 1)
35+
.collect();
3536

3637
// Assign FUEL and ORE known indices as we'll need to look them up later.
3738
let mut indices = FastMap::new();

‎src/year2023/day06.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
//! [quadratic formula](https://en.wikipedia.org/wiki/Quadratic_formula).
2020
//!
2121
//! * `(t ± √(t2 - 4d)) / 2`
22-
use crate::util::math::*;
2322
use crate::util::parse::*;
2423

2524
pub fn parse(input: &str) -> Vec<&str> {
@@ -45,7 +44,7 @@ fn race(first: &str, second: &str) -> u128 {
4544

4645
for (time, distance) in times.zip(distances) {
4746
// Use the quadratic formula to find the start and end positions.
48-
let root = (time * time - 4 * distance).sqrt();
47+
let root = (time * time - 4 * distance).isqrt();
4948
let mut start = (time - root).div_ceil(2);
5049
let mut end = (time + root) / 2;
5150

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /