rustlings icon indicating copy to clipboard operation
rustlings copied to clipboard

feat: add functions6.rs and move_semantics6.rs exercises about closures

Open rikettsie opened this issue 2 years ago • 2 comments

This PR contains a couple of exercises about closures, one in the 02_functions group, the other in the 06_move_semantics. Hints and documentation references are added to correctly complete the exercises.

rikettsie avatar Nov 01 '23 21:11 rikettsie

I am a student learning Rust, and while I support adding exercises about closures to Rustlings, I think it would be unfair and needlessly difficult for students to add those exercises to the 02_functions and 06_move_semantics section of Rustlings, because closures are considered a more advanced feature of Rust, and they are not described till later in the Rust book.

A student who is a beginner with learning rust, and is following along the Rust book would find these exercises too hard for their level of learning, and would not be able to skip them easily.

Issue #1937 relates to how the order of some exercises is slightly different from the book, but for that issue it would be fairly easy for the student to read ahead and solve the problems. For these exercises you propose, I don't think a student could realistically read ahead because there are a great many concepts that would need to be understood to get that far into the book.

Could you create another section for these and other advanced exercises ?

chrestomanci avatar Jul 05 '24 13:07 chrestomanci

@chrestomanci, your point makes sense, but as you say your perspective comes from your personal learning experience, and I think we should always be careful when reasoning about what is a good learning path, as there's no standard one.

Very often, gently introducing harder concepts earlier, allows one to better take them on later for deeper understanding.

In this case, because rust heavily supports functional patterns, you may argue that it's not too early to bring the student a taste of those special functions, namely closures, suggesting how they behave differently (e.g. in "passing" in parameters) right after studying function usage.

The idea here is this is only an introduction suggesting for more room later, i.e. a dedicated chapter probably before iterators and mappers, as these components leverage functional rust with the full expressivity of closures.

A discussion about such a dedicated chapter is going on with the PR #1746 if you want to join.

rikettsie avatar Sep 30 '24 05:09 rikettsie