You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I'd like to thank you for all the hard work that has gone into building this codebase. I've been telling myself for years now that I should learn rust, and with your help I've just started to write my first rust code. There's a lot I still don't know about rust, so this issue may be very naive.
After installing rust version 1.45.0 I began working through the koans until I got to arrays.rs which has a test to cause a panic with an invalid array index, as you can see below :
// Attempting to access an array at an index that is// out of its bounds will cause an error. Let's cause// that error in this example.#[test]#[should_panic]#[allow(const_err)]fnout_of_index(){let arr:[&'static str;5] = ["rust","is","mostly","for","nerds"];
arr[__];}
However, I was unable to make this pass by simply using an invalid index such as 6. With a little bit of googling I was able to find out that you can add a trait to allow for unconditional panics.
// Attempting to access an array at an index that is// out of its bounds will cause an error. Let's cause// that error in this example.#[test]#[should_panic]#[allow(const_err)]#[alllow(unconditional_panic)]// <<<< this is the line I needed to addfnout_of_index(){let arr:[&'static str;5] = ["rust","is","mostly","for","nerds"];
arr[666];}
It seems like one of the following is true
I don't fully understand this koan
the trait [allow(const_err)] should be changed to #[alllow(unconditional_panic)]
If the second is true I would be more than happy to issue you a pull request.
The text was updated successfully, but these errors were encountered:
buchananta
added a commit
to buchananta/rust-koans
that referenced
this issue
Feb 5, 2021
Hello, I'd like to thank you for all the hard work that has gone into building this codebase. I've been telling myself for years now that I should learn rust, and with your help I've just started to write my first rust code. There's a lot I still don't know about rust, so this issue may be very naive.
After installing rust version 1.45.0 I began working through the koans until I got to
arrays.rs
which has a test to cause a panic with an invalid array index, as you can see below :However, I was unable to make this pass by simply using an invalid index such as 6. With a little bit of googling I was able to find out that you can add a trait to allow for unconditional panics.
It seems like one of the following is true
[allow(const_err)]
should be changed to#[alllow(unconditional_panic)]
If the second is true I would be more than happy to issue you a pull request.
The text was updated successfully, but these errors were encountered: