I read "for x in 2i32.." as meaning "for signed integer values of x from 2 to whatever the maximum possible positive value of a 32 bit integer is"
Well, in reality it will panic on overflow with overflow checks enabled, and is unbounded with overflow checks disabled. So, practically, the final line of the function is unreachable.
Looks like your function f() should return an Error or perhaps an Option so as to ensure the caller is forced to check the return value properly.
It should not return an error or option if the developer believes the function will always return a value. If the code is returning unexpected values, that's a code bug, and not one that can be mitigated by merely passing the buck to the calling function. The result of
None is wholly unexpected, and would therefore not likely to be properly handled anymore-so than