From 1d991f7aab504280dc0b6e80997e3082ea866e16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Sp=C3=B6ttel?= <1682504+fspoettel@users.noreply.github.com> Date: Sat, 29 Oct 2022 14:32:33 +0200 Subject: [PATCH] docs: add common pitfalls section --- README.md | 6 +++++- src/bin/download.rs | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f3dca54..573fdbe 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ Individual solutions live in the `./src/bin/` directory as separate binaries. Every [solution](https://github.com/fspoettel/advent-of-code-rust/blob/master/src/bin/scaffold.rs#L7-L35) has _unit tests_ referencing its _example_ file. Use these unit tests to develop and debug your solution against example inputs. For some puzzles, it might be easier to forgo the example file and hardcode inputs into the tests. -When editing a solution, `rust-analyzer` will display buttons for these actions above the unit tests. +When editing a solution, `rust-analyzer` will display buttons for running / debugging unit tests above the unit test blocks. ### Download input for a day @@ -182,3 +182,7 @@ Go to the _Secrets_ tab in your repository settings and create the following sec - [regex](https://crates.io/crates/regex): Official regular expressions implementation for Rust. Do you have aoc-specific crate recommendations? [Share them!](https://github.com/fspoettel/advent-of-code-rust/edit/master/README.md) + +## Common pitfalls + +* **Integer overflows:** This template uses 32-bit integers by default because it is generally faster - for example when packed in large arrays or structs - than using 64-bit integers everywhere. For some problems, solutions for real input might exceed 32-bit integer space. While this is checked and panics in `debug` mode, integers [wrap](https://doc.rust-lang.org/book/ch03-02-data-types.html#integer-overflow) in `release` mode, leading to wrong output when running your solution. diff --git a/src/bin/download.rs b/src/bin/download.rs index 0db8714..8c09679 100644 --- a/src/bin/download.rs +++ b/src/bin/download.rs @@ -5,7 +5,7 @@ use std::{fs, process}; struct Args { day: u8, - year: Option, + year: Option, } fn parse_args() -> Result {