Skip to content

aocgen/templates: add template for Rust solutions #122

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

Merged
merged 1 commit into from
Jan 22, 2020
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
35 changes: 35 additions & 0 deletions aocgen/templates/rust/src/yearYYYY/dayDD.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
use std::io;

use crate::base::Part;

pub fn part1(r: &mut dyn io::Read) -> Result<String, String> {
solve(r, Part::One)
}

pub fn part2(r: &mut dyn io::Read) -> Result<String, String> {
solve(r, Part::Two)
}

fn solve(r: &mut dyn io::Read, part: Part) -> Result<String, String> {
Err("not implemented yet".to_string())
}

#[cfg(test)]
mod tests {
use super::*;
use crate::test;

mod part1 {
use super::*;

test!(example, "", "", part1);
test!(actual, file "../../../inputs/{{.Year}}/{{.PaddedDay}}", "", part1);
}

// mod part2 {
// use super::*;

// test!(example, "", "", part2);
// test!(actual, file "../../../inputs/{{.Year}}/{{.PaddedDay}}", "", part2);
// }
}
6 changes: 6 additions & 0 deletions aocgen/templates/rust/src/yearYYYY/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// NOTE: this has overwritten the previous `mod.rs`. If this is not what you
// want, simply add `pub mod {{.FullDay}};` at the end of the current `mod.rs`.
// Also: remember to add `pub mod {{.FullYear}}` to `src/lib.rs` for `cargo` to
// actually pick up the `{{.FullYear}}` module as well as the `{{.FullDay}}`
// module.
pub mod {{.FullDay}};