This exercise appears to be poorly designed due to an inconsistency in the required behavior and function signatures. Specifically, the specification demands invalidating inputs that contain anything other than lowercase letters (returning None
), yet one of the functions (encode_random
) must return a (String, String)
tuple without an option to signal invalid input. This contradiction forces an assumption that encode_random
is only called with valid inputs, which is not clearly stated and makes the API inconsistent and confusing. Ideally, the exercise should either unify the error handling strategy across all functions or provide a clearer guideline on handling invalid inputs in encode_random
.
Which track (programming language) are you referring to?
====> Rust
This is false. There are only tests against keys with uppercase letters. The message to encode can be anything.
So it makes perfect sense that the encode_random
function is infallible, because the user doesn’t provide the key. The function generates the key itself and is therefore capable of ensuring the key is strictly lowercase.