@@ -276,10 +276,10 @@ where
276276}
277277
278278macro_rules! impl_ {
279- ( $uxx: ident) => {
279+ ( $uxx: ident, $doc : tt $ ( , $unsf : ident ) ? ) => {
280280 impl <T , const N : usize > Queue <T , $uxx, N > {
281- /// Creates an empty queue with a fixed capacity of `N`
282- pub const fn $uxx( ) -> Self {
281+ # [ doc = $doc ]
282+ pub const $ ( $unsf ) * fn $uxx( ) -> Self {
283283 Self {
284284 head: Atomic :: new( 0 ) ,
285285 tail: Atomic :: new( 0 ) ,
@@ -296,7 +296,7 @@ macro_rules! impl_ {
296296 /// ```
297297 /// use heapless::spsc::Queue;
298298 ///
299- /// let mut queue: Queue<u8, _, 235> = Queue::u8 ();
299+ /// let mut queue: Queue<u8, _, 235> = Queue::new ();
300300 /// let (mut producer, mut consumer) = queue.split();
301301 /// assert_eq!(None, consumer.peek());
302302 /// producer.enqueue(1);
@@ -414,9 +414,17 @@ impl<T, const N: usize> Queue<T, usize, N> {
414414 }
415415}
416416
417- impl_ ! ( u8 ) ;
418- impl_ ! ( u16 ) ;
419- impl_ ! ( usize ) ;
417+ impl_ ! (
418+ u8 ,
419+ "Creates an empty queue with a fixed capacity of `N`. **Safety**: Assumes `N <= u8::MAX`." ,
420+ unsafe
421+ ) ;
422+ impl_ ! (
423+ u16 ,
424+ "Creates an empty queue with a fixed capacity of `N`. **Safety**: Assumes `N <= u16::MAX`." ,
425+ unsafe
426+ ) ;
427+ impl_ ! ( usize , "Creates an empty queue with a fixed capacity of `N`" ) ;
420428
421429impl < T , U , U2 , const N : usize , const N2 : usize > PartialEq < Queue < T , U2 , N2 > > for Queue < T , U , N >
422430where
@@ -633,7 +641,7 @@ mod tests {
633641
634642 #[ test]
635643 fn iter_overflow ( ) {
636- let mut rb: Queue < i32 , u8 , 4 > = Queue :: u8 ( ) ;
644+ let mut rb: Queue < i32 , u8 , 4 > = unsafe { Queue :: u8 ( ) } ;
637645
638646 rb. enqueue ( 0 ) . unwrap ( ) ;
639647 for _ in 0 ..300 {
0 commit comments