@@ -171,53 +171,55 @@ impl fmt::Display for TooBigForRelativeBlockHeightError {
171171#[ cfg( feature = "std" ) ]
172172impl std:: error:: Error for TooBigForRelativeBlockHeightError { }
173173
174- // height - height = interval
175- impl ops:: Sub < BlockHeight > for BlockHeight {
176- type Output = BlockInterval ;
177-
178- fn sub ( self , rhs : BlockHeight ) -> Self :: Output {
179- let interval = self . to_u32 ( ) - rhs. to_u32 ( ) ;
180- BlockInterval :: from_u32 ( interval)
174+ crate :: internal_macros:: impl_op_for_references! {
175+ // height - height = interval
176+ impl ops:: Sub <BlockHeight > for BlockHeight {
177+ type Output = BlockInterval ;
178+
179+ fn sub( self , rhs: BlockHeight ) -> Self :: Output {
180+ let interval = self . to_u32( ) - rhs. to_u32( ) ;
181+ BlockInterval :: from_u32( interval)
182+ }
181183 }
182- }
183184
184- // height + interval = height
185- impl ops:: Add < BlockInterval > for BlockHeight {
186- type Output = BlockHeight ;
185+ // height + interval = height
186+ impl ops:: Add <BlockInterval > for BlockHeight {
187+ type Output = BlockHeight ;
187188
188- fn add ( self , rhs : BlockInterval ) -> Self :: Output {
189- let height = self . to_u32 ( ) + rhs. to_u32 ( ) ;
190- BlockHeight :: from_u32 ( height)
189+ fn add( self , rhs: BlockInterval ) -> Self :: Output {
190+ let height = self . to_u32( ) + rhs. to_u32( ) ;
191+ BlockHeight :: from_u32( height)
192+ }
191193 }
192- }
193194
194- // height - interval = height
195- impl ops:: Sub < BlockInterval > for BlockHeight {
196- type Output = BlockHeight ;
195+ // height - interval = height
196+ impl ops:: Sub <BlockInterval > for BlockHeight {
197+ type Output = BlockHeight ;
197198
198- fn sub ( self , rhs : BlockInterval ) -> Self :: Output {
199- let height = self . to_u32 ( ) - rhs. to_u32 ( ) ;
200- BlockHeight :: from_u32 ( height)
199+ fn sub( self , rhs: BlockInterval ) -> Self :: Output {
200+ let height = self . to_u32( ) - rhs. to_u32( ) ;
201+ BlockHeight :: from_u32( height)
202+ }
201203 }
202- }
203204
204- // interval + interval = interval
205- impl ops:: Add < BlockInterval > for BlockInterval {
206- type Output = BlockInterval ;
205+ // interval + interval = interval
206+ impl ops:: Add <BlockInterval > for BlockInterval {
207+ type Output = BlockInterval ;
207208
208- fn add ( self , rhs : BlockInterval ) -> Self :: Output {
209- let height = self . to_u32 ( ) + rhs. to_u32 ( ) ;
210- BlockInterval :: from_u32 ( height)
209+ fn add( self , rhs: BlockInterval ) -> Self :: Output {
210+ let height = self . to_u32( ) + rhs. to_u32( ) ;
211+ BlockInterval :: from_u32( height)
212+ }
211213 }
212- }
213214
214- // interval - interval = interval
215- impl ops:: Sub < BlockInterval > for BlockInterval {
216- type Output = BlockInterval ;
215+ // interval - interval = interval
216+ impl ops:: Sub <BlockInterval > for BlockInterval {
217+ type Output = BlockInterval ;
217218
218- fn sub ( self , rhs : BlockInterval ) -> Self :: Output {
219- let height = self . to_u32 ( ) - rhs. to_u32 ( ) ;
220- BlockInterval :: from_u32 ( height)
219+ fn sub( self , rhs: BlockInterval ) -> Self :: Output {
220+ let height = self . to_u32( ) - rhs. to_u32( ) ;
221+ BlockInterval :: from_u32( height)
222+ }
221223 }
222224}
223225
0 commit comments