Comments (6)
Hum, input is trimmed to ease parsing (for example, when parsing a number on each line) here :
cargo-aoc/aoc-runner/src/lib.rs
Line 17 in 52164ce
There is currently no way to turn it off :/
from cargo-aoc.
Oh okay, I missed that while I was looking through the source. It might be worth mentioning that in the readme (or adding a way to turn it off) since it threw me for a loop this morning. My parser depended on a trailing newline for each passport and although it was easy enough to fix I didn't realize I needed to do that.
from cargo-aoc.
What would be the use case for stripping the trailing newline? str::lines
is probably the best way to split a string like this into lines and it gives the same result with and without a trailing newline.
from cargo-aoc.
You're right, a flag to prevent trimming could be nice. After a glance at some old inputs, it still seems like a good default to me.
from cargo-aoc.
I would go as far as saying it would make sense to not trim anything at all - because otherwise a solution that works without cargo-aoc may not work with it, and vice versa.
from cargo-aoc.
So I'm pretty much zombifying this issue, but this behavior is absolutely unexpected and should not be the default imo.
Trimming the input in your solution or a generator function is literally one line, if you actually need it. Efficiently untrimming the input on the other hand is pretty much impossible without bad hacks.
This breaks for example a possible optimized solution with array_chunks::<4>()
for aoc2022 day2. All lines consist of a structure like A X\n
, which is exactly 4 bytes. When the trailing newline is trimmed, this skipps the last line and stops working.
from cargo-aoc.
Related Issues (20)
- Unexpected error occurs when running `cargo aoc` without any subcommands HOT 1
- Running `Cargo aoc -g` doesn't generate new file HOT 3
- cargo aoc fails to compile solution HOT 2
- [feat request] cargo-aoc test
- Naming a type `Box` produces crazy errors
- Cannot install cargo-aoc HOT 1
- Unexpected type argument? HOT 1
- The solving functions cannot receive a mutable reference HOT 2
- How do I debug with cargo-aoc HOT 3
- Lifetime error with `#[aoc...` HOT 1
- Allow overriding criterion configs
- Feature request: cargo aoc init
- Cannot download input from 2020: error 400 (credentials are set) HOT 1
- rust-analyzer macro-error everywhere HOT 2
- What are 'named solutions' in aoc_generate
- aoc_generator(day, part) seems broken HOT 3
- Can't get minimal example to work HOT 3
- Include contact info in user agent HOT 2
- Add a way to run in release mode with `cargo aoc --release` HOT 2
- Update docs
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cargo-aoc.