1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
use crate::modular::{
modulo::{Modulo, ModuloLarge, ModuloRepr, ModuloSmall},
modulo_ring::{ModuloRing, ModuloRingLarge, ModuloRingSmall},
};
use core::ptr;
impl PartialEq for ModuloRing {
fn eq(&self, other: &Self) -> bool {
ptr::eq(self, other)
}
}
impl Eq for ModuloRing {}
impl PartialEq for ModuloRingSmall {
fn eq(&self, other: &Self) -> bool {
ptr::eq(self, other)
}
}
impl Eq for ModuloRingSmall {}
impl PartialEq for ModuloRingLarge {
fn eq(&self, other: &Self) -> bool {
ptr::eq(self, other)
}
}
impl Eq for ModuloRingLarge {}
impl PartialEq for Modulo<'_> {
fn eq(&self, other: &Self) -> bool {
match (self.repr(), other.repr()) {
(ModuloRepr::Small(self_small), ModuloRepr::Small(other_small)) => {
self_small.eq(other_small)
}
(ModuloRepr::Large(self_large), ModuloRepr::Large(other_large)) => {
self_large.eq(other_large)
}
_ => Modulo::panic_different_rings(),
}
}
}
impl Eq for Modulo<'_> {}
impl PartialEq for ModuloSmall<'_> {
fn eq(&self, other: &Self) -> bool {
self.check_same_ring(other);
self.normalized_value() == other.normalized_value()
}
}
impl Eq for ModuloLarge<'_> {}
impl PartialEq for ModuloLarge<'_> {
fn eq(&self, other: &Self) -> bool {
self.check_same_ring(other);
self.normalized_value() == other.normalized_value()
}
}