Z^m number system in Rust
I would hesitate to implement Mod&lt;T&gt; * Mod&lt;T&gt;, and instead implement Mod&lt;T&gt; * T (and vice-versa). This is because you make no attempt to preserve the rhs' modulo, so you probably shouldn't have one there.

Consider the code

let mut x: i32 = *self;
while x.signum() != n.signum() {
    x += n;
}
x % n


That while loop makes this operation \$\mathcal{O}(n)\$, whereas a simpler implementation

((x % n) + n) % n


is \$\mathcal{O}(1)\$.

Performance elsewhere is probably uninteresting, since it devolves to basic integer operations.

Extending to other T should probably be done by being generic over the Mod and Add traits, as well as whatever particular operation is needed to implement. Something like

impl&lt;T&gt; Sub&lt;T&gt; for Mod&lt;T&gt;
    where T: Add&lt;T&gt; + Mod&lt;T&gt; + Sub&lt;T&gt;
{
    type Output = Mod&lt;T&gt;;
    fn sub(self, other: T) -&gt; Mod&lt;T&gt; {
        Mod::new(self.modulo, self.i - i)
    }
}


The Add and Mod are needed by Mod::new, the Sub is needed inside the sub call.