2021: setup boilerplate
This commit is contained in:
parent
ebc57d58b6
commit
d5c85d4a17
16
Cargo.lock
generated
16
Cargo.lock
generated
|
@ -82,6 +82,22 @@ dependencies = [
|
|||
"criterion",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aoc2021"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"aoc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aoc2021_bench"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"aoc2021",
|
||||
"criterion",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "arrayvec"
|
||||
version = "0.5.2"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[workspace]
|
||||
members = ["aoc*", "aoc*/aoc*_bench"]
|
||||
|
||||
default-members = ["aoc2020"]
|
||||
default-members = ["aoc2021"]
|
||||
|
||||
[profile.release]
|
||||
debug = true
|
||||
|
|
18
aoc2021/Cargo.toml
Normal file
18
aoc2021/Cargo.toml
Normal file
|
@ -0,0 +1,18 @@
|
|||
[package]
|
||||
name = "aoc2021"
|
||||
version = "0.1.0"
|
||||
authors = ["Antoine Martin <antoine97.martin@gmail.com>"]
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
aoc = { path = "../aoc" }
|
||||
anyhow = "1.0"
|
||||
|
||||
[lib]
|
||||
path = "src/lib.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "aoc2021"
|
||||
path = "src/main.rs"
|
17
aoc2021/aoc2021_bench/Cargo.toml
Normal file
17
aoc2021/aoc2021_bench/Cargo.toml
Normal file
|
@ -0,0 +1,17 @@
|
|||
[package]
|
||||
name = "aoc2021_bench"
|
||||
version = "0.1.0"
|
||||
authors = ["Antoine Martin <antoine97.martin@gmail.com>"]
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
aoc2021 = { path = "../" }
|
||||
|
||||
[dev-dependencies]
|
||||
criterion = "0.3"
|
||||
|
||||
[[bench]]
|
||||
name = "aoc2021_bench"
|
||||
harness = false
|
14
aoc2021/aoc2021_bench/benches/aoc2021_bench.rs
Normal file
14
aoc2021/aoc2021_bench/benches/aoc2021_bench.rs
Normal file
|
@ -0,0 +1,14 @@
|
|||
use criterion::{criterion_group, criterion_main, Criterion};
|
||||
|
||||
use aoc2021::day00;
|
||||
|
||||
fn aoc2021_all(c: &mut Criterion) {
|
||||
c.bench_function("day00", |b| b.iter(|| day00::run().unwrap()));
|
||||
}
|
||||
|
||||
criterion_group! {
|
||||
name = all_days;
|
||||
config = Criterion::default().sample_size(200);
|
||||
targets = aoc2021_all
|
||||
}
|
||||
criterion_main!(all_days);
|
1
aoc2021/input/day00.txt
Normal file
1
aoc2021/input/day00.txt
Normal file
|
@ -0,0 +1 @@
|
|||
Hello world!
|
17
aoc2021/src/day00.rs
Normal file
17
aoc2021/src/day00.rs
Normal file
|
@ -0,0 +1,17 @@
|
|||
use std::fmt::Write;
|
||||
|
||||
use anyhow::Result;
|
||||
|
||||
const INPUT: &str = include_str!("../input/day00.txt");
|
||||
|
||||
pub fn run() -> Result<String> {
|
||||
let mut res = String::with_capacity(128);
|
||||
|
||||
writeln!(res, "part 1: {}", part1(INPUT)?)?;
|
||||
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
fn part1(input: &str) -> Result<&str> {
|
||||
Ok(input)
|
||||
}
|
3
aoc2021/src/lib.rs
Normal file
3
aoc2021/src/lib.rs
Normal file
|
@ -0,0 +1,3 @@
|
|||
#![warn(clippy::explicit_iter_loop, clippy::redundant_closure_for_method_calls)]
|
||||
|
||||
pub mod day00;
|
11
aoc2021/src/main.rs
Normal file
11
aoc2021/src/main.rs
Normal file
|
@ -0,0 +1,11 @@
|
|||
use anyhow::Result;
|
||||
|
||||
use aoc::DayFunc;
|
||||
|
||||
use aoc2021::day00;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let days: &[DayFunc] = &[day00::run];
|
||||
|
||||
aoc::run(days)
|
||||
}
|
Loading…
Reference in a new issue