rust-lang / rustlings

:crab: Small exercises to get you used to reading and writing Rust code!
https://rustlings.cool
MIT License
52.69k stars 10.02k forks source link

Incorrect solution for `move_semnatics5.rs` #2081

Closed divyaranjan1905 closed 1 month ago

divyaranjan1905 commented 1 month ago

The problem in move_semnatic5.rs specifically mentions:

// TODO: Fix the compiler errors without changing anything except adding or removing references (the character `&`).

This means, one must not do anything other than just adding &. But, the corresponding solution to it in is the following: https://github.com/rust-lang/rustlings/blame/ce3dcc98560a7555386556ba13d5e901bb27e2ed/solutions/06_move_semantics/move_semantics5.rs#L11

The solution adds a new mut to the data argument of the function, this is not a valid solution according to the question. I know this resolves the compiler errors and it works smoothly, but it is not correct with respect to the problem that has been posed.

mo8it commented 1 month ago

I am confused. mut is also in the exercise:

https://github.com/rust-lang/rustlings/blob/ce3dcc98560a7555386556ba13d5e901bb27e2ed/exercises/06_move_semantics/move_semantics5.rs#L12

Am I missing something?

divyaranjan1905 commented 1 month ago

I think I messed it up and then forgot that mut was already there, apologies for not double-checking. It's all good. Thank you for rustlings.

mo8it commented 1 month ago

No problem. You are welcome :D