rstmt_core/pitch/impls/
impl_pclass_ops.rs1use crate::pitch::pitch_class::PitchClass;
7use crate::pitch::traits::{RawAccidental, RawPitchClass};
8use rstmt_traits::PitchMod;
9
10impl<T1, A1, T2, A2> core::ops::Add<PitchClass<T2, A2>> for PitchClass<T1, A1>
18where
19 T1: RawPitchClass<Tag = A1>,
20 A1: RawAccidental,
21 T2: RawPitchClass<Tag = A2>,
22 A2: RawAccidental,
23{
24 type Output = isize;
25
26 fn add(self, rhs: PitchClass<T2, A2>) -> Self::Output {
27 (self.get().index() + rhs.get().index()).pmod()
28 }
29}
30
31impl<T1, A1, T2, A2> core::ops::Sub<PitchClass<T2, A2>> for PitchClass<T1, A1>
32where
33 T1: RawPitchClass<Tag = A1>,
34 A1: RawAccidental,
35 T2: RawPitchClass<Tag = A2>,
36 A2: RawAccidental,
37{
38 type Output = isize;
40
41 fn sub(self, rhs: PitchClass<T2, A2>) -> Self::Output {
42 (self.get().index() - rhs.get().index()).pmod()
43 }
44}