-
Notifications
You must be signed in to change notification settings - Fork 7
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
rely less on macros #29
base: main
Are you sure you want to change the base?
Conversation
This makes the tool easier to maintain and extend for the future. Also, the future of GATs might allow some flexibility.
@@ -46,7 +46,7 @@ mod day2 { | |||
} | |||
|
|||
mod day3 { | |||
pub fn generator(_: &str) -> Option<&str> { | |||
pub fn generator(_: String) -> Option<String> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Asked to comment here from my PR fixing borrowed data in returned iterators.
Ultimately, this crate and aoc-runner/'cargo aoc' are just conveniences. When folk are doing the competitive side of AOC, Rust is probably the wrong choice for most if not all puzzles - countless one-liners in numpy for instance are faster to create because of the super high level capabilities there.
What I and some others I know do is just do it in Rust for fun. For the lols. And there we end up playing code golf and seeing how fast we can get some algorithms. Last year I had some down to 300ns - and the generator was 4us - 10x slower than the actual runner.
In that scenario there was nothing borrowed, but sometimes it is convenient to just return a generator straight from stack where no allocations take place, and then for that being able to
a) borrow the input and return a struct with borrowed refers from the generator and
b) borrow the input passed to the runner to process it (with a cheap clone since the whole struct is a handful of words)
... is super convenient.
It was in fact one of the things that brought me to aoc-main vs 'cargo aoc'.
The other thing I'd love is a better way to manage many-year collections of aoc puzzles. Right now I use branches, because both aoc-main and aoc-runner want to both own the entry point, but not provide a year multiplexer.
I solved this borrow issue by leaking the input (which means we can borrow it statically and we don't have to pass along values that look like Now that I have a working core I'll still try to iterate on it, trying to make something more elegant. |
This makes the tool easier to maintain and extend for the future. Also, the future of GATs might allow some flexibility.