When I compile and execute a RUST program, I receive the error 'thread' main 'panicked at' attempt to shift left with overflow '. This seems to be due to the automatic overflow check by cargo causing the program to fail. How can I prohibit overflow checks? In which files are modifications made?
What I think would be best is that you find an answer to this question:
What would you like this function to return when shift is 32?
If you don't know the answer to this, then its rather difficult to help you. I can come up with some answer that I think is reasonable and tell you how to implement that, but ultimately, the correct answer depends on how you're using pow2_size, and the behavior I suggest might be incorrect for your application.
Your function has the possibility to try and produce a number that is bigger than the u32 it returns can represent. I think you have to decide what the result should be in that case.
That panic is trying to tell the programmer that their program has a bug. A situation that if allowed to proceed would make no sense. Something they have not thought about.
I notice the code contains a check for a shift of zero, why not add a check for a shift bigger than 31?
Having added that check you will have to decide what the return value should be in the error case. Or perhaps this function should return a Result type.