How to check usize parameter is within range

I have a method that uses usize index as a parameter. Instead of using an enum containing the correct values to choose from it is less verbose to check the range. However, I can not get it to build

assert_eq!((3..32.contains(&index)),true);

This line gives error, can't call method 'contains' on ambiguous type '{integer}'
If I change to this

assert_eq!((3..32_usize.contains(&index)),true);

I get method not found in 'usize' and expected struct 'Range', found 'bool'

What is the correct way to do this?

EDIT
I tried it on the playground and it works?

Try adding parentheses like (3..32).contains…

1 Like

Wow, how did I miss that :slight_smile: