File tree Expand file tree Collapse file tree 2 files changed +4
-7
lines changed Expand file tree Collapse file tree 2 files changed +4
-7
lines changed Original file line number Diff line number Diff line change 9898//! [`with_capacity_and_hasher`][IndexMap::with_capacity_and_hasher] instead.
9999//! A no-std compatible hasher will be needed as well, for example
100100//! from the crate `twox-hash`.
101- //! - Macros [`indexmap!`] and [`indexset!`] are unavailable without `std`.
102101
103102#![ cfg_attr( docsrs, feature( doc_cfg) ) ]
104103
Original file line number Diff line number Diff line change 1- #[ cfg( feature = "std" ) ]
2- #[ cfg_attr( docsrs, doc( cfg( feature = "std" ) ) ) ]
31#[ macro_export]
42/// Create an [`IndexMap`][crate::IndexMap] from a list of key-value pairs
53///
@@ -26,7 +24,8 @@ macro_rules! indexmap {
2624 // Note: `stringify!($key)` is just here to consume the repetition,
2725 // but we throw away that string literal during constant evaluation.
2826 const CAP : usize = <[ ( ) ] >:: len( & [ $( { stringify!( $key) ; } ) ,* ] ) ;
29- let mut map = $crate:: IndexMap :: with_capacity( CAP ) ;
27+ #[ allow( unused_mut) ]
28+ let mut map = $crate:: IndexMap :: with_capacity_and_hasher( CAP , <_>:: default ( ) ) ;
3029 $(
3130 map. insert( $key, $value) ;
3231 ) *
@@ -35,8 +34,6 @@ macro_rules! indexmap {
3534 } ;
3635}
3736
38- #[ cfg( feature = "std" ) ]
39- #[ cfg_attr( docsrs, doc( cfg( feature = "std" ) ) ) ]
4037#[ macro_export]
4138/// Create an [`IndexSet`][crate::IndexSet] from a list of values
4239///
@@ -63,7 +60,8 @@ macro_rules! indexset {
6360 // Note: `stringify!($value)` is just here to consume the repetition,
6461 // but we throw away that string literal during constant evaluation.
6562 const CAP : usize = <[ ( ) ] >:: len( & [ $( { stringify!( $value) ; } ) ,* ] ) ;
66- let mut set = $crate:: IndexSet :: with_capacity( CAP ) ;
63+ #[ allow( unused_mut) ]
64+ let mut set = $crate:: IndexSet :: with_capacity_with_hasher( CAP , <_>:: default ( ) ) ;
6765 $(
6866 set. insert( $value) ;
6967 ) *
You can’t perform that action at this time.
0 commit comments