Skip to content

Commit 1d991f7

Browse files
committed
docs: add common pitfalls section
1 parent b82974c commit 1d991f7

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Individual solutions live in the `./src/bin/` directory as separate binaries.
4848

4949
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.
5050

51-
When editing a solution, `rust-analyzer` will display buttons for these actions above the unit tests.
51+
When editing a solution, `rust-analyzer` will display buttons for running / debugging unit tests above the unit test blocks.
5252

5353
### Download input for a day
5454

@@ -182,3 +182,7 @@ Go to the _Secrets_ tab in your repository settings and create the following sec
182182
- [regex](https://crates.io/crates/regex): Official regular expressions implementation for Rust.
183183

184184
Do you have aoc-specific crate recommendations? [Share them!](https://github.com/fspoettel/advent-of-code-rust/edit/master/README.md)
185+
186+
## Common pitfalls
187+
188+
* **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.

src/bin/download.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::{fs, process};
55

66
struct Args {
77
day: u8,
8-
year: Option<u32>,
8+
year: Option<i16>,
99
}
1010

1111
fn parse_args() -> Result<Args, pico_args::Error> {

0 commit comments

Comments
 (0)