Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update toolchain, switch to coroutines, use release lto in CI #218

Merged
merged 4 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/run.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:

- name: Run cargo build
run: |
cargo build --release
cargo build --profile release-lto
env:
RUSTFLAGS: "-C target-cpu=native"

Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2023-07-20"
channel = "nightly-2023-12-05"
components = [ "rustfmt", "clippy" ]
2 changes: 1 addition & 1 deletion src/aoc2022/day17.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ fn set(v: &mut Vec<bool>, index: usize) {
v[index] = true;
}

fn get(v: &Vec<bool>, index: usize) -> bool {
fn get(v: &[bool], index: usize) -> bool {
if index >= v.len() {
false
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/aoc2022/day18.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ fn neighbors(
z: usize,
width: usize,
) -> impl Iterator<Item = (usize, usize, usize)> {
std::iter::from_generator(move || {
std::iter::from_coroutine(move || {
if x > 0 {
yield (x - 1, y, z);
}
Expand Down
2 changes: 1 addition & 1 deletion src/aoc2022/day19.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ impl State {
let min_use = bp.min_use;
let max_use = bp.max_use;

std::iter::from_generator(move || {
std::iter::from_coroutine(move || {
// not buying
let mut ns = self;
ns.collect();
Expand Down
2 changes: 1 addition & 1 deletion src/aoc2022/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl<T> Grid<T> {
pub fn get_neighbors(&self, x: usize, y: usize) -> impl Iterator<Item = (usize, usize)> {
let width = self.width;
let height = self.height;
std::iter::from_generator(move || {
std::iter::from_coroutine(move || {
if x != 0 {
yield (x - 1, y);
}
Expand Down
4 changes: 2 additions & 2 deletions src/aoc2023/day3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl Entry {
&'a self,
grid: &'b Grid<u8>,
) -> impl Iterator<Item = (usize, usize)> + 'b {
std::iter::from_generator(move || {
std::iter::from_coroutine(move || {
let x = self.x as i32;
let y = self.y as i32;
let len = self.len as i32;
Expand All @@ -61,7 +61,7 @@ impl Entry {

#[inline]
fn get_entries(input: &Grid<u8>) -> impl Iterator<Item = Entry> + '_ {
std::iter::from_generator(move || {
std::iter::from_coroutine(move || {
let mut current = None;
for y in 0..input.height {
for x in 0..input.width {
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#![feature(iter_array_chunks)]
#![feature(array_windows)]
#![feature(get_many_mut)]
#![feature(generators)]
#![feature(iter_from_generator)]
#![feature(coroutines)]
#![feature(iter_from_coroutine)]

use std::time::Duration;

Expand Down