@@ -61,7 +61,7 @@ impl<B, C: Channel, T: Target> Transfer<B, C, T> {
6161 // method we can call is `write_buffer`, which is allowed by
6262 // `WriteBuffer`'s safety requirements.
6363 let ( ptr, len) = unsafe { buffer. write_buffer ( ) } ;
64- let len = u16:: try_from ( len) . expect ( "buffer is too large" ) ;
64+ let len = crate :: expect! ( u16 :: try_from( len) . ok ( ) , "buffer is too large" ) ;
6565
6666 // NOTE(unsafe) We are using the address of a 'static WriteBuffer here,
6767 // which is guaranteed to be safe for DMA.
@@ -88,7 +88,7 @@ impl<B, C: Channel, T: Target> Transfer<B, C, T> {
8888 // `&mut self` methods we can call, so we are safe according to
8989 // `ReadBuffer`'s safety requirements.
9090 let ( ptr, len) = unsafe { buffer. read_buffer ( ) } ;
91- let len = u16:: try_from ( len) . expect ( "buffer is too large" ) ;
91+ let len = crate :: expect! ( u16 :: try_from( len) . ok ( ) , "buffer is too large" ) ;
9292
9393 // NOTE(unsafe) We are using the address of a 'static ReadBuffer here,
9494 // which is guaranteed to be safe for DMA.
@@ -110,7 +110,7 @@ impl<B, C: Channel, T: Target> Transfer<B, C, T> {
110110 where
111111 T : OnChannel < C > ,
112112 {
113- assert ! ( !channel. is_enabled( ) ) ;
113+ crate :: assert!( !channel. is_enabled( ) ) ;
114114
115115 atomic:: compiler_fence ( Ordering :: Release ) ;
116116
@@ -128,13 +128,13 @@ impl<B, C: Channel, T: Target> Transfer<B, C, T> {
128128
129129 /// Is this transfer complete?
130130 pub fn is_complete ( & self ) -> bool {
131- let inner = self . inner . as_ref ( ) . unwrap ( ) ;
131+ let inner = crate :: unwrap! ( self . inner. as_ref( ) ) ;
132132 inner. channel . event_occurred ( Event :: TransferComplete )
133133 }
134134
135135 /// Stop this transfer and return ownership over its parts
136136 pub fn stop ( mut self ) -> ( B , C , T ) {
137- let mut inner = self . inner . take ( ) . unwrap ( ) ;
137+ let mut inner = crate :: unwrap! ( self . inner. take( ) ) ;
138138 inner. stop ( ) ;
139139
140140 ( inner. buffer , inner. channel , inner. target )
@@ -280,7 +280,7 @@ pub trait Channel: private::Channel {
280280 /// Callers must ensure the given address is the address of a peripheral
281281 /// register that supports DMA.
282282 unsafe fn set_peripheral_address ( & mut self , address : u32 , inc : Increment ) {
283- assert ! ( !self . is_enabled( ) ) ;
283+ crate :: assert!( !self . is_enabled( ) ) ;
284284
285285 self . ch ( ) . par . write ( |w| w. pa ( ) . bits ( address) ) ;
286286 self . ch ( ) . cr . modify ( |_, w| w. pinc ( ) . variant ( inc. into ( ) ) ) ;
@@ -300,7 +300,7 @@ pub trait Channel: private::Channel {
300300 /// Callers must ensure the given address is a valid memory address
301301 /// that will remain valid as long as at is used by DMA.
302302 unsafe fn set_memory_address ( & mut self , address : u32 , inc : Increment ) {
303- assert ! ( !self . is_enabled( ) ) ;
303+ crate :: assert!( !self . is_enabled( ) ) ;
304304
305305 self . ch ( ) . mar . write ( |w| w. ma ( ) . bits ( address) ) ;
306306 self . ch ( ) . cr . modify ( |_, w| w. minc ( ) . variant ( inc. into ( ) ) ) ;
@@ -314,7 +314,7 @@ pub trait Channel: private::Channel {
314314 ///
315315 /// Panics if this channel is enabled.
316316 fn set_transfer_length ( & mut self , len : u16 ) {
317- assert ! ( !self . is_enabled( ) ) ;
317+ crate :: assert!( !self . is_enabled( ) ) ;
318318
319319 self . ch ( ) . ndtr . write ( |w| w. ndt ( ) . bits ( len) ) ;
320320 }
@@ -331,7 +331,7 @@ pub trait Channel: private::Channel {
331331 1 => BITS8 ,
332332 2 => BITS16 ,
333333 4 => BITS32 ,
334- s => panic ! ( "unsupported word size: {}" , s) ,
334+ s => crate :: panic!( "unsupported word size: {:? }" , s) ,
335335 } ;
336336
337337 self . ch ( ) . cr . modify ( |_, w| {
0 commit comments