@@ -6,7 +6,7 @@ use crate::io::prelude::*;
66use crate :: alloc:: Allocator ;
77use crate :: cmp;
88use crate :: io:: { self , BorrowedCursor , ErrorKind , IoSlice , IoSliceMut , SeekFrom } ;
9- use core :: alloc;
9+ use :: alloc:: { co_alloc :: CoAllocPref , meta_num_slots } ;
1010
1111/// A `Cursor` wraps an in-memory buffer and provides it with a
1212/// [`Seek`] implementation.
@@ -398,13 +398,14 @@ fn slice_write_vectored(
398398}
399399
400400/// Reserves the required space, and pads the vec with 0s if necessary.
401+ #[ allow( unused_braces) ]
401402fn reserve_and_pad < A : Allocator , const CO_ALLOC_PREF : CoAllocPref > (
402403 pos_mut : & mut u64 ,
403404 vec : & mut Vec < u8 , A , CO_ALLOC_PREF > ,
404405 buf_len : usize ,
405406) -> io:: Result < usize >
406407where
407- [ ( ) ; alloc :: co_alloc_metadata_num_slots_with_preference :: < A > ( CO_ALLOC_PREF ) ] : ,
408+ [ ( ) ; { meta_num_slots ! ( A , CO_ALLOC_PREF ) } ] : ,
408409{
409410 let pos: usize = ( * pos_mut) . try_into ( ) . map_err ( |_| {
410411 io:: const_io_error!(
@@ -444,14 +445,15 @@ where
444445
445446/// Writes the slice to the vec without allocating
446447/// # Safety: vec must have buf.len() spare capacity
448+ #[ allow( unused_braces) ]
447449unsafe fn vec_write_unchecked < A , const CO_ALLOC_PREF : CoAllocPref > (
448450 pos : usize ,
449451 vec : & mut Vec < u8 , A , CO_ALLOC_PREF > ,
450452 buf : & [ u8 ] ,
451453) -> usize
452454where
453455 A : Allocator ,
454- [ ( ) ; alloc :: co_alloc_metadata_num_slots_with_preference :: < A > ( CO_ALLOC_PREF ) ] : ,
456+ [ ( ) ; { meta_num_slots ! ( A , CO_ALLOC_PREF ) } ] : ,
455457{
456458 debug_assert ! ( vec. capacity( ) >= pos + buf. len( ) ) ;
457459 vec. as_mut_ptr ( ) . add ( pos) . copy_from ( buf. as_ptr ( ) , buf. len ( ) ) ;
@@ -467,14 +469,15 @@ where
467469/// This also allows for the vec body to be empty, but with a position of N.
468470/// This means that [`Write`] will pad the vec with 0 initially,
469471/// before writing anything from that point
472+ #[ allow( unused_braces) ]
470473fn vec_write < A , const CO_ALLOC_PREF : CoAllocPref > (
471474 pos_mut : & mut u64 ,
472475 vec : & mut Vec < u8 , A , CO_ALLOC_PREF > ,
473476 buf : & [ u8 ] ,
474477) -> io:: Result < usize >
475478where
476479 A : Allocator ,
477- [ ( ) ; alloc :: co_alloc_metadata_num_slots_with_preference :: < A > ( CO_ALLOC_PREF ) ] : ,
480+ [ ( ) ; { meta_num_slots ! ( A , CO_ALLOC_PREF ) } ] : ,
478481{
479482 let buf_len = buf. len ( ) ;
480483 let mut pos = reserve_and_pad ( pos_mut, vec, buf_len) ?;
@@ -503,14 +506,15 @@ where
503506/// This also allows for the vec body to be empty, but with a position of N.
504507/// This means that [`Write`] will pad the vec with 0 initially,
505508/// before writing anything from that point
509+ #[ allow( unused_braces) ]
506510fn vec_write_vectored < A , const CO_ALLOC_PREF : CoAllocPref > (
507511 pos_mut : & mut u64 ,
508512 vec : & mut Vec < u8 , A , CO_ALLOC_PREF > ,
509513 bufs : & [ IoSlice < ' _ > ] ,
510514) -> io:: Result < usize >
511515where
512516 A : Allocator ,
513- [ ( ) ; alloc :: co_alloc_metadata_num_slots_with_preference :: < A > ( CO_ALLOC_PREF ) ] : ,
517+ [ ( ) ; { meta_num_slots ! ( A , CO_ALLOC_PREF ) } ] : ,
514518{
515519 // For safety reasons, we don't want this sum to overflow ever.
516520 // If this saturates, the reserve should panic to avoid any unsound writing.
@@ -558,10 +562,11 @@ impl Write for Cursor<&mut [u8]> {
558562}
559563
560564#[ stable( feature = "cursor_mut_vec" , since = "1.25.0" ) ]
565+ #[ allow( unused_braces) ]
561566impl < A , const CO_ALLOC_PREF : CoAllocPref > Write for Cursor < & mut Vec < u8 , A , CO_ALLOC_PREF > >
562567where
563568 A : Allocator ,
564- [ ( ) ; alloc :: co_alloc_metadata_num_slots_with_preference :: < A > ( CO_ALLOC_PREF ) ] : ,
569+ [ ( ) ; { meta_num_slots ! ( A , CO_ALLOC_PREF ) } ] : ,
565570{
566571 fn write ( & mut self , buf : & [ u8 ] ) -> io:: Result < usize > {
567572 vec_write ( & mut self . pos , self . inner , buf)
@@ -583,10 +588,11 @@ where
583588}
584589
585590#[ stable( feature = "rust1" , since = "1.0.0" ) ]
591+ #[ allow( unused_braces) ]
586592impl < A , const CO_ALLOC_PREF : CoAllocPref > Write for Cursor < Vec < u8 , A , CO_ALLOC_PREF > >
587593where
588594 A : Allocator ,
589- [ ( ) ; alloc :: co_alloc_metadata_num_slots_with_preference :: < A > ( CO_ALLOC_PREF ) ] : ,
595+ [ ( ) ; { meta_num_slots ! ( A , CO_ALLOC_PREF ) } ] : ,
590596{
591597 fn write ( & mut self , buf : & [ u8 ] ) -> io:: Result < usize > {
592598 vec_write ( & mut self . pos , & mut self . inner , buf)
0 commit comments