Skip to content

Commit be01c92

Browse files
authored
Merge pull request #351 from paulcacheux/bump-toolchain-2024
Bump toolchain 2024
2 parents 6b21e80 + e8888ce commit be01c92

File tree

9 files changed

+127
-112
lines changed

9 files changed

+127
-112
lines changed

rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "nightly-2023-12-17"
2+
channel = "nightly-2024-11-26"
33
components = [ "rustfmt", "clippy" ]

src/aoc2021/day3.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ pub struct MaskedBits<'b> {
9494
pub line_mask: Vec<bool>,
9595
}
9696

97-
impl<'b> Deref for MaskedBits<'b> {
97+
impl Deref for MaskedBits<'_> {
9898
type Target = OptimizedBits;
9999

100100
fn deref(&self) -> &OptimizedBits {

src/aoc2022/day17.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ fn dbg_state(state: &Vec<Vec<bool>>) {
8585

8686
#[inline]
8787
fn solve(input: &[i32], steps: usize) -> usize {
88-
let blocks = vec![
88+
let blocks = [
8989
vec![
9090
[true, false, false, false],
9191
[true, false, false, false],

src/aoc2022/day18.rs

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -83,26 +83,29 @@ fn neighbors(
8383
z: usize,
8484
width: usize,
8585
) -> impl Iterator<Item = (usize, usize, usize)> {
86-
std::iter::from_coroutine(move || {
87-
if x > 0 {
88-
yield (x - 1, y, z);
89-
}
90-
if x + 1 < width {
91-
yield (x + 1, y, z);
92-
}
93-
if y > 0 {
94-
yield (x, y - 1, z);
95-
}
96-
if y + 1 < width {
97-
yield (x, y + 1, z);
98-
}
99-
if z > 0 {
100-
yield (x, y, z - 1);
101-
}
102-
if z + 1 < width {
103-
yield (x, y, z + 1);
104-
}
105-
})
86+
std::iter::from_coroutine(
87+
#[coroutine]
88+
move || {
89+
if x > 0 {
90+
yield (x - 1, y, z);
91+
}
92+
if x + 1 < width {
93+
yield (x + 1, y, z);
94+
}
95+
if y > 0 {
96+
yield (x, y - 1, z);
97+
}
98+
if y + 1 < width {
99+
yield (x, y + 1, z);
100+
}
101+
if z > 0 {
102+
yield (x, y, z - 1);
103+
}
104+
if z + 1 < width {
105+
yield (x, y, z + 1);
106+
}
107+
},
108+
)
106109
}
107110

108111
struct Cube3D {

src/aoc2022/day19.rs

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -234,37 +234,40 @@ impl State {
234234
let min_use = bp.min_use;
235235
let max_use = bp.max_use;
236236

237-
std::iter::from_coroutine(move || {
238-
// not buying
239-
let mut ns = self;
240-
ns.collect();
241-
ns.move_ahead::<STEPS>(min_use);
242-
yield ns;
243-
244-
// buying
245-
if let Some(mut next) = self.can_buy(geode_bot) {
246-
// directly add all geodes instead of creating a robot
247-
next.key.geode += (STEPS - ns.step) as u16;
248-
yield next;
249-
}
250-
if self.key.bot.obsidian < max_use.obsidian {
251-
if let Some(mut next) = self.can_buy(obs_bot) {
252-
next.key.bot.obsidian += 1;
237+
std::iter::from_coroutine(
238+
#[coroutine]
239+
move || {
240+
// not buying
241+
let mut ns = self;
242+
ns.collect();
243+
ns.move_ahead::<STEPS>(min_use);
244+
yield ns;
245+
246+
// buying
247+
if let Some(mut next) = self.can_buy(geode_bot) {
248+
// directly add all geodes instead of creating a robot
249+
next.key.geode += (STEPS - ns.step) as u16;
253250
yield next;
254251
}
255-
}
256-
if self.key.bot.clay < max_use.clay {
257-
if let Some(mut next) = self.can_buy(clay_bot) {
258-
next.key.bot.clay += 1;
259-
yield next;
252+
if self.key.bot.obsidian < max_use.obsidian {
253+
if let Some(mut next) = self.can_buy(obs_bot) {
254+
next.key.bot.obsidian += 1;
255+
yield next;
256+
}
260257
}
261-
}
262-
if self.key.bot.ore < max_use.ore {
263-
if let Some(mut next) = self.can_buy(ore_bot) {
264-
next.key.bot.ore += 1;
265-
yield next;
258+
if self.key.bot.clay < max_use.clay {
259+
if let Some(mut next) = self.can_buy(clay_bot) {
260+
next.key.bot.clay += 1;
261+
yield next;
262+
}
266263
}
267-
}
268-
})
264+
if self.key.bot.ore < max_use.ore {
265+
if let Some(mut next) = self.can_buy(ore_bot) {
266+
next.key.bot.ore += 1;
267+
yield next;
268+
}
269+
}
270+
},
271+
)
269272
}
270273
}

src/aoc2023/day3.rs

Lines changed: 52 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -36,63 +36,69 @@ impl Entry {
3636
&'a self,
3737
grid: &'b Grid<u8>,
3838
) -> impl Iterator<Item = (usize, usize)> + 'b {
39-
std::iter::from_coroutine(move || {
40-
let x = self.x as i32;
41-
let y = self.y as i32;
42-
let len = self.len as i32;
43-
44-
maybe_yield!(grid, x - 1, y - 1);
45-
for dx in 0..len {
46-
maybe_yield!(grid, x + dx, y - 1);
47-
}
48-
maybe_yield!(grid, x + len, y - 1);
39+
std::iter::from_coroutine(
40+
#[coroutine]
41+
move || {
42+
let x = self.x as i32;
43+
let y = self.y as i32;
44+
let len = self.len as i32;
45+
46+
maybe_yield!(grid, x - 1, y - 1);
47+
for dx in 0..len {
48+
maybe_yield!(grid, x + dx, y - 1);
49+
}
50+
maybe_yield!(grid, x + len, y - 1);
4951

50-
maybe_yield!(grid, x - 1, y);
51-
maybe_yield!(grid, x + len, y);
52+
maybe_yield!(grid, x - 1, y);
53+
maybe_yield!(grid, x + len, y);
5254

53-
maybe_yield!(grid, x - 1, y + 1);
54-
for dx in 0..len {
55-
maybe_yield!(grid, x + dx, y + 1);
56-
}
57-
maybe_yield!(grid, x + len, y + 1);
58-
})
55+
maybe_yield!(grid, x - 1, y + 1);
56+
for dx in 0..len {
57+
maybe_yield!(grid, x + dx, y + 1);
58+
}
59+
maybe_yield!(grid, x + len, y + 1);
60+
},
61+
)
5962
}
6063
}
6164

6265
#[inline]
6366
fn get_entries(input: &Grid<u8>) -> impl Iterator<Item = Entry> + '_ {
64-
std::iter::from_coroutine(move || {
65-
let mut current = None;
66-
for y in 0..input.height {
67-
for x in 0..input.width {
68-
let c = *input.get(x, y);
69-
if c.is_ascii_digit() {
70-
let digit = (c - b'0') as u32;
71-
72-
current = match current {
73-
Some(Entry { x, y, len, value }) => Some(Entry {
74-
x,
75-
y,
76-
len: len + 1,
77-
value: value * 10 + digit,
78-
}),
79-
None => Some(Entry {
80-
x,
81-
y,
82-
len: 1,
83-
value: digit,
84-
}),
67+
std::iter::from_coroutine(
68+
#[coroutine]
69+
move || {
70+
let mut current = None;
71+
for y in 0..input.height {
72+
for x in 0..input.width {
73+
let c = *input.get(x, y);
74+
if c.is_ascii_digit() {
75+
let digit = (c - b'0') as u32;
76+
77+
current = match current {
78+
Some(Entry { x, y, len, value }) => Some(Entry {
79+
x,
80+
y,
81+
len: len + 1,
82+
value: value * 10 + digit,
83+
}),
84+
None => Some(Entry {
85+
x,
86+
y,
87+
len: 1,
88+
value: digit,
89+
}),
90+
}
91+
} else if let Some(entry) = current.take() {
92+
yield entry;
8593
}
86-
} else if let Some(entry) = current.take() {
87-
yield entry;
8894
}
8995
}
90-
}
9196

92-
if let Some(entry) = current {
93-
yield entry;
94-
}
95-
})
97+
if let Some(entry) = current {
98+
yield entry;
99+
}
100+
},
101+
)
96102
}
97103

98104
#[derive(Debug, Clone)]

src/grid.rs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,20 +73,23 @@ impl<T> Grid<T> {
7373
) -> impl Iterator<Item = (Direction, usize, usize)> {
7474
let width = self.width;
7575
let height = self.height;
76-
std::iter::from_coroutine(move || {
77-
if x != 0 {
78-
yield (Direction::West, x - 1, y);
79-
}
80-
if y != 0 {
81-
yield (Direction::North, x, y - 1);
82-
}
83-
if x != width - 1 {
84-
yield (Direction::East, x + 1, y);
85-
}
86-
if y != height - 1 {
87-
yield (Direction::South, x, y + 1);
88-
}
89-
})
76+
std::iter::from_coroutine(
77+
#[coroutine]
78+
move || {
79+
if x != 0 {
80+
yield (Direction::West, x - 1, y);
81+
}
82+
if y != 0 {
83+
yield (Direction::North, x, y - 1);
84+
}
85+
if x != width - 1 {
86+
yield (Direction::East, x + 1, y);
87+
}
88+
if y != height - 1 {
89+
yield (Direction::South, x, y + 1);
90+
}
91+
},
92+
)
9093
}
9194
}
9295

src/helpers.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ macro_rules! inner_run {
7676
}
7777

7878
pub struct TimingData {
79+
#[allow(dead_code)]
7980
pub parsing: Duration,
8081
pub part1: Duration,
8182
pub part2: Duration,

src/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#![feature(get_many_mut)]
44
#![feature(coroutines)]
55
#![feature(iter_from_coroutine)]
6-
#![feature(is_sorted)]
76

87
use std::time::Duration;
98

0 commit comments

Comments
 (0)