exercism / rust

Exercism exercises in Rust.
https://exercism.org/tracks/rust
MIT License
1.45k stars 521 forks source link

Macros exercise missing checks #1610

Closed yulin-physics closed 1 year ago

yulin-physics commented 1 year ago

More tests could be added for the Macros exercise, one specific case I found is when there is no separator between fragments current test set still passes e.g.

HashMap<u32, u32> = hashmap!(1=>1 1=>1);

For the top community solution with the hashmap macro definition:

#[macro_export]
macro_rules! hashmap {
    ($( $key: expr => $val: expr )+$(,)?) => {{
         let mut map = ::std::collections::HashMap::new();
         $( map.insert($key, $val); )*
         map
    }}
}
github-actions[bot] commented 1 year ago

Hello. Thanks for opening an issue on Exercism. We are currently in a phase of our journey where we have paused community contributions to allow us to take a breather and redesign our community model. You can learn more in this blog post. As such, all issues and PRs in this repository are being automatically closed.

That doesn't mean we're not interested in your ideas, or that if you're stuck on something we don't want to help. The best place to discuss things is with our community on the Exercism Community Forum. You can use this link%20=%3E%20%7B%7B%0D%0A%20%20%20%20%20%20%20%20%20let%20mut%20map%20=%20::std::collections::HashMap::new();%0D%0A%20%20%20%20%20%20%20%20%20$(%20map.insert($key,%20$val);%20)*%0D%0A%20%20%20%20%20%20%20%20%20map%0D%0A%20%20%20%20%7D%7D%0D%0A%7D%0D%0A%60%60%60&category=rust) to copy this into a new topic there.


Note: If this issue has been pre-approved, please link back to this issue on the forum thread and a maintainer or staff member will reopen it.

senekor commented 1 year ago

@yulin-physics This solution already doesn't compile for me locally. It's not the top one in the community solution either, maybe it has changed in the meantime. Maybe you can provide a link?

Either way, I think there actually is already a test for missing commas(?) https://github.com/exercism/rust/blob/main/exercises/practice/macros/tests/invalid/no-comma.rs

yulin-physics commented 1 year ago

@senekor Does look like the "invalid" solution disappeared from community solutions and no longer passes the tests, I'm happy for you to close this issue : ) Thank you!