Create advent prelude and cleanup lint by using it.

This commit is contained in:
Bill Thiede 2021-12-16 20:10:01 -08:00
parent 1fb9a8416d
commit 232b2687ca
10 changed files with 64 additions and 44 deletions

13
.gitignore vendored
View File

@ -1 +1,14 @@
**/target/
# Added by cargo
/target
# Added by cargo
#
# already existing elements were commented out
#/target
Cargo.lock

12
2021/Cargo.lock generated
View File

@ -2,10 +2,22 @@
# It is not intended for manual editing.
version = 3
[[package]]
name = "advent"
version = "0.1.0"
dependencies = [
"anyhow",
"aoc-runner",
"aoc-runner-derive",
"pretty_assertions",
"thiserror",
]
[[package]]
name = "advent2021"
version = "0.1.0"
dependencies = [
"advent",
"ansi_term",
"anyhow",
"aoc-runner",

View File

@ -12,3 +12,4 @@ aoc-runner = "0.3.0"
aoc-runner-derive = "0.3.0"
pretty_assertions = "1.0.0"
thiserror = "1.0.30"
advent = { path = "../" }

View File

@ -1,13 +1,5 @@
use std::{
fmt::{Debug, Error, Formatter},
num::ParseIntError,
ops::{Index, IndexMut},
str::FromStr,
};
use anyhow::Result;
use aoc_runner_derive::{aoc, aoc_generator};
use thiserror::Error;
use advent::prelude::*;
use aoc_runner_derive::aoc;
struct Image {
width: usize,
@ -182,7 +174,7 @@ fn part2(input: &str) -> Result<usize> {
mod tests {
use super::*;
//#[test]
#[test]
fn test_part1() -> Result<()> {
let input = r#"
6,10

View File

@ -1,15 +1,5 @@
use std::{
collections::{HashMap, HashSet, VecDeque},
convert::Infallible,
fmt::{Debug, Error, Formatter},
num::ParseIntError,
ops::{Index, IndexMut},
str::FromStr,
};
use anyhow::Result;
use aoc_runner_derive::{aoc, aoc_generator};
use thiserror::Error;
use advent::prelude::*;
use aoc_runner_derive::aoc;
struct Image {
width: usize,

View File

@ -1,14 +1,5 @@
use std::{
fmt::{Debug, Error, Formatter},
io::Read,
num::ParseIntError,
ops::{Index, IndexMut},
str::FromStr,
};
use anyhow::Result;
use aoc_runner_derive::{aoc, aoc_generator};
use thiserror::Error;
use advent::prelude::*;
use aoc_runner_derive::aoc;
fn hex(b: &u8) -> u8 {
if *b >= b'A' {

View File

@ -3,7 +3,7 @@ pub mod day10;
pub mod day11;
pub mod day12;
pub mod day13;
pub mod day14;
//pub mod day14;
pub mod day15;
pub mod day16;
pub mod day2;

View File

@ -1,13 +1,5 @@
use std::{
fmt::{Debug, Error, Formatter},
num::ParseIntError,
ops::{Index, IndexMut},
str::FromStr,
};
use anyhow::Result;
use advent::prelude::*;
use aoc_runner_derive::{aoc, aoc_generator};
use thiserror::Error;
#[aoc(dayX, part1)]
fn part1(input: &str) -> Result<usize> {

16
Cargo.toml Normal file
View File

@ -0,0 +1,16 @@
[package]
name = "advent"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
anyhow = "1.0.45"
aoc-runner = "0.3.0"
aoc-runner-derive = "0.3.0"
pretty_assertions = "1.0.0"
thiserror = "1.0.30"
[lib]
name = "advent"

13
src/lib.rs Normal file
View File

@ -0,0 +1,13 @@
pub mod prelude {
pub use std::{
convert::Infallible,
fmt::{Debug, Error, Formatter},
io::Read,
num::ParseIntError,
ops::{Index, IndexMut},
str::FromStr,
};
pub use anyhow::Result;
pub use thiserror::Error;
}