Does Rust have a modulo operation (not remainder)?
Hello everyone! I recently started learning Rust, coming from Python, and encountered an unexpected problem. In Python, I'm used to the `%` operator always returning a non-negative result, i.e., the mathematical modulo. For example, `(-5) % 3` in Python gives `1`. This is very convenient for cyclic indices, working with clocks, days of the week, and any ring arithmetic.
But in Rust, the `%` operator, as I found out, returns the remainder, not the modulo. And for negative numbers it behaves differently: `(-5) % 3` in Rust gives `-2`. This breaks all my logic! I'm writing a simple function for shifting an index in an array:
```rust
fn shift_index(current: usize, delta: i32, len: usize) -> usize {
let new_index = (current as i32 + delta) % len as i32;
new_index as usize
}
```
When `delta`