Skip to content

Commit f3fc799

Browse files
committed
use self
1 parent 5b8f780 commit f3fc799

File tree

5 files changed

+120
-120
lines changed

5 files changed

+120
-120
lines changed

src/bars.rs

+28-28
Original file line numberDiff line numberDiff line change
@@ -82,84 +82,84 @@ impl Bars {
8282

8383
impl From<NumDiv> for Bars {
8484
fn from(n: NumDiv) -> Self {
85-
Bars(n)
85+
Self(n)
8686
}
8787
}
8888

8989
impl Add for Bars {
90-
type Output = Bars;
90+
type Output = Self;
9191
#[inline]
92-
fn add(self, rhs: Bars) -> Bars {
93-
Bars(self.bars() + rhs.bars())
92+
fn add(self, rhs: Self) -> Self {
93+
Self(self.bars() + rhs.bars())
9494
}
9595
}
9696

9797
impl Sub for Bars {
98-
type Output = Bars;
98+
type Output = Self;
9999
#[inline]
100-
fn sub(self, rhs: Bars) -> Bars {
101-
Bars(self.bars() - rhs.bars())
100+
fn sub(self, rhs: Self) -> Self {
101+
Self(self.bars() - rhs.bars())
102102
}
103103
}
104104

105105
impl Mul for Bars {
106-
type Output = Bars;
106+
type Output = Self;
107107
#[inline]
108-
fn mul(self, rhs: Bars) -> Bars {
109-
Bars(self.bars() * rhs.bars())
108+
fn mul(self, rhs: Self) -> Self {
109+
Self(self.bars() * rhs.bars())
110110
}
111111
}
112112

113113
impl Div for Bars {
114-
type Output = Bars;
114+
type Output = Self;
115115
#[inline]
116-
fn div(self, rhs: Bars) -> Bars {
117-
Bars(self.bars() / rhs.bars())
116+
fn div(self, rhs: Self) -> Self {
117+
Self(self.bars() / rhs.bars())
118118
}
119119
}
120120

121121
impl Rem for Bars {
122-
type Output = Bars;
122+
type Output = Self;
123123
#[inline]
124-
fn rem(self, rhs: Bars) -> Bars {
125-
Bars(self.bars() % rhs.bars())
124+
fn rem(self, rhs: Self) -> Self {
125+
Self(self.bars() % rhs.bars())
126126
}
127127
}
128128

129129
impl Neg for Bars {
130-
type Output = Bars;
130+
type Output = Self;
131131
#[inline]
132-
fn neg(self) -> Bars {
133-
Bars(-self.bars())
132+
fn neg(self) -> Self {
133+
Self(-self.bars())
134134
}
135135
}
136136

137137
impl AddAssign for Bars {
138-
fn add_assign(&mut self, rhs: Bars) {
138+
fn add_assign(&mut self, rhs: Self) {
139139
*self = *self + rhs;
140140
}
141141
}
142142

143143
impl SubAssign for Bars {
144-
fn sub_assign(&mut self, rhs: Bars) {
144+
fn sub_assign(&mut self, rhs: Self) {
145145
*self = *self - rhs;
146146
}
147147
}
148148

149149
impl MulAssign for Bars {
150-
fn mul_assign(&mut self, rhs: Bars) {
150+
fn mul_assign(&mut self, rhs: Self) {
151151
*self = *self * rhs;
152152
}
153153
}
154154

155155
impl DivAssign for Bars {
156-
fn div_assign(&mut self, rhs: Bars) {
156+
fn div_assign(&mut self, rhs: Self) {
157157
*self = *self / rhs;
158158
}
159159
}
160160

161161
impl RemAssign for Bars {
162-
fn rem_assign(&mut self, rhs: Bars) {
162+
fn rem_assign(&mut self, rhs: Self) {
163163
*self = *self % rhs;
164164
}
165165
}
@@ -174,10 +174,10 @@ impl ToPrimitive for Bars {
174174
}
175175

176176
impl FromPrimitive for Bars {
177-
fn from_u64(n: u64) -> Option<Bars> {
178-
Some(Bars(n as NumDiv))
177+
fn from_u64(n: u64) -> Option<Self> {
178+
Some(Self(n as NumDiv))
179179
}
180-
fn from_i64(n: i64) -> Option<Bars> {
181-
Some(Bars(n as NumDiv))
180+
fn from_i64(n: i64) -> Option<Self> {
181+
Some(Self(n as NumDiv))
182182
}
183183
}

src/beats.rs

+29-29
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ impl Beats {
3434

3535
/// Return the number of beats.
3636
#[inline]
37-
pub fn beats(&self) -> NumDiv { let Beats(num) = *self; num }
37+
pub fn beats(&self) -> NumDiv { let Self(num) = *self; num }
3838

3939
/// Convert to the equivalent duration as a number of Bars.
4040
#[inline]
@@ -82,84 +82,84 @@ impl Beats {
8282

8383
impl From<NumDiv> for Beats {
8484
fn from(n: NumDiv) -> Self {
85-
Beats(n)
85+
Self(n)
8686
}
8787
}
8888

8989
impl Add for Beats {
90-
type Output = Beats;
90+
type Output = Self;
9191
#[inline]
92-
fn add(self, rhs: Beats) -> Beats {
93-
Beats(self.beats() + rhs.beats())
92+
fn add(self, rhs: Self) -> Self {
93+
Self(self.beats() + rhs.beats())
9494
}
9595
}
9696

9797
impl Sub for Beats {
98-
type Output = Beats;
98+
type Output = Self;
9999
#[inline]
100-
fn sub(self, rhs: Beats) -> Beats {
101-
Beats(self.beats() - rhs.beats())
100+
fn sub(self, rhs: Self) -> Self {
101+
Self(self.beats() - rhs.beats())
102102
}
103103
}
104104

105105
impl Mul for Beats {
106-
type Output = Beats;
106+
type Output = Self;
107107
#[inline]
108-
fn mul(self, rhs: Beats) -> Beats {
109-
Beats(self.beats() * rhs.beats())
108+
fn mul(self, rhs: Self) -> Self {
109+
Self(self.beats() * rhs.beats())
110110
}
111111
}
112112

113113
impl Div for Beats {
114-
type Output = Beats;
114+
type Output = Self;
115115
#[inline]
116-
fn div(self, rhs: Beats) -> Beats {
117-
Beats(self.beats() / rhs.beats())
116+
fn div(self, rhs: Self) -> Self {
117+
Self(self.beats() / rhs.beats())
118118
}
119119
}
120120

121121
impl Rem for Beats {
122-
type Output = Beats;
122+
type Output = Self;
123123
#[inline]
124-
fn rem(self, rhs: Beats) -> Beats {
125-
Beats(self.beats() % rhs.beats())
124+
fn rem(self, rhs: Self) -> Self {
125+
Self(self.beats() % rhs.beats())
126126
}
127127
}
128128

129129
impl Neg for Beats {
130-
type Output = Beats;
130+
type Output = Self;
131131
#[inline]
132-
fn neg(self) -> Beats {
133-
Beats(-self.beats())
132+
fn neg(self) -> Self {
133+
Self(-self.beats())
134134
}
135135
}
136136

137137
impl AddAssign for Beats {
138-
fn add_assign(&mut self, rhs: Beats) {
138+
fn add_assign(&mut self, rhs: Self) {
139139
*self = *self + rhs;
140140
}
141141
}
142142

143143
impl SubAssign for Beats {
144-
fn sub_assign(&mut self, rhs: Beats) {
144+
fn sub_assign(&mut self, rhs: Self) {
145145
*self = *self - rhs;
146146
}
147147
}
148148

149149
impl MulAssign for Beats {
150-
fn mul_assign(&mut self, rhs: Beats) {
150+
fn mul_assign(&mut self, rhs: Self) {
151151
*self = *self * rhs;
152152
}
153153
}
154154

155155
impl DivAssign for Beats {
156-
fn div_assign(&mut self, rhs: Beats) {
156+
fn div_assign(&mut self, rhs: Self) {
157157
*self = *self / rhs;
158158
}
159159
}
160160

161161
impl RemAssign for Beats {
162-
fn rem_assign(&mut self, rhs: Beats) {
162+
fn rem_assign(&mut self, rhs: Self) {
163163
*self = *self % rhs;
164164
}
165165
}
@@ -174,10 +174,10 @@ impl ToPrimitive for Beats {
174174
}
175175

176176
impl FromPrimitive for Beats {
177-
fn from_u64(n: u64) -> Option<Beats> {
178-
Some(Beats(n as NumDiv))
177+
fn from_u64(n: u64) -> Option<Self> {
178+
Some(Self(n as NumDiv))
179179
}
180-
fn from_i64(n: i64) -> Option<Beats> {
181-
Some(Beats(n as NumDiv))
180+
fn from_i64(n: i64) -> Option<Self> {
181+
Some(Self(n as NumDiv))
182182
}
183183
}

src/ms.rs

+23-23
Original file line numberDiff line numberDiff line change
@@ -77,79 +77,79 @@ impl From<calc::Ms> for Ms {
7777
}
7878

7979
impl Add for Ms {
80-
type Output = Ms;
80+
type Output = Self;
8181
#[inline]
82-
fn add(self, rhs: Ms) -> Ms {
83-
Ms(self.ms() + rhs.ms())
82+
fn add(self, rhs: Self) -> Self {
83+
Self(self.ms() + rhs.ms())
8484
}
8585
}
8686

8787
impl Sub for Ms {
88-
type Output = Ms;
88+
type Output = Self;
8989
#[inline]
90-
fn sub(self, rhs: Ms) -> Ms {
91-
Ms(self.ms() - rhs.ms())
90+
fn sub(self, rhs: Self) -> Self {
91+
Self(self.ms() - rhs.ms())
9292
}
9393
}
9494

9595
impl Mul for Ms {
96-
type Output = Ms;
96+
type Output = Self;
9797
#[inline]
98-
fn mul(self, rhs: Ms) -> Ms {
99-
Ms(self.ms() * rhs.ms())
98+
fn mul(self, rhs: Self) -> Self {
99+
Self(self.ms() * rhs.ms())
100100
}
101101
}
102102

103103
impl Div for Ms {
104-
type Output = Ms;
104+
type Output = Self;
105105
#[inline]
106-
fn div(self, rhs: Ms) -> Ms {
107-
Ms(self.ms() / rhs.ms())
106+
fn div(self, rhs: Self) -> Self {
107+
Self(self.ms() / rhs.ms())
108108
}
109109
}
110110

111111
impl Rem for Ms {
112-
type Output = Ms;
112+
type Output = Self;
113113
#[inline]
114-
fn rem(self, rhs: Ms) -> Ms {
115-
Ms(self.ms() % rhs.ms())
114+
fn rem(self, rhs: Self) -> Self {
115+
Self(self.ms() % rhs.ms())
116116
}
117117
}
118118

119119
impl Neg for Ms {
120-
type Output = Ms;
120+
type Output = Self;
121121
#[inline]
122-
fn neg(self) -> Ms {
123-
Ms(-self.ms())
122+
fn neg(self) -> Self {
123+
Self(-self.ms())
124124
}
125125
}
126126

127127
impl AddAssign for Ms {
128-
fn add_assign(&mut self, rhs: Ms) {
128+
fn add_assign(&mut self, rhs: Self) {
129129
*self = *self + rhs;
130130
}
131131
}
132132

133133
impl SubAssign for Ms {
134-
fn sub_assign(&mut self, rhs: Ms) {
134+
fn sub_assign(&mut self, rhs: Self) {
135135
*self = *self - rhs;
136136
}
137137
}
138138

139139
impl MulAssign for Ms {
140-
fn mul_assign(&mut self, rhs: Ms) {
140+
fn mul_assign(&mut self, rhs: Self) {
141141
*self = *self * rhs;
142142
}
143143
}
144144

145145
impl DivAssign for Ms {
146-
fn div_assign(&mut self, rhs: Ms) {
146+
fn div_assign(&mut self, rhs: Self) {
147147
*self = *self / rhs;
148148
}
149149
}
150150

151151
impl RemAssign for Ms {
152-
fn rem_assign(&mut self, rhs: Ms) {
152+
fn rem_assign(&mut self, rhs: Self) {
153153
*self = *self % rhs;
154154
}
155155
}

0 commit comments

Comments
 (0)