rustlings
rustlings copied to clipboard
Canonical Solutions
Hello!
It would be great if after you complete a file, it showed you a "good" solution. Sometimes it's hard to tell if I cheated on accident, or didn't learn the lesson I was supposed to.
The hints feature is great and kinda serves this purpose, but I'd still appreciate solutions to the problems after I do them myself :)
I'm voting for this! 🌻
It's nice to see different ways to solve a problem, we can even put several solutions for each exercise.
For example - primitive_types3.rs
Creating an array with at least 100 elements- a short Google search would yield something like:
let a = [0; 500];
but the hints also say:
Bonus: what are some other things you could have that would return true for
a.len() >= 100
?
I didn't have any idea.. and it'd be cool to encounter a different approach :)
@itayperry I guess taking advantage of rust
's awesome features like monomorphization, std
, core
, generics, traits, etc, is the way to go.
@kaiuri I just started learning :) so it would take a while. In short, regarding the issue at hand, I'm absolutely up for adding canonical solutions for all the exercises.
@kaiuri I just started learning :) so it would take a while. In short, regarding the issue at hand, I'm absolutely up for adding canonical solutions for all the exercises.
Hmmm... I think Rust is too expressive for canonical, maybe the most idiomatic solution would result in something approaching uniqueness.
Possible duplicate of #293
That would be such a great feature! Rustlings is a awesome for learning the language but it would be great to compare ones own solution with an idiomatic "optimal" solution