File tree 2 files changed +4
-7
lines changed
2 files changed +4
-7
lines changed Original file line number Diff line number Diff line change 98
98
//! [`with_capacity_and_hasher`][IndexMap::with_capacity_and_hasher] instead.
99
99
//! A no-std compatible hasher will be needed as well, for example
100
100
//! from the crate `twox-hash`.
101
- //! - Macros [`indexmap!`] and [`indexset!`] are unavailable without `std`.
102
101
103
102
#![ cfg_attr( docsrs, feature( doc_cfg) ) ]
104
103
Original file line number Diff line number Diff line change 1
- #[ cfg( feature = "std" ) ]
2
- #[ cfg_attr( docsrs, doc( cfg( feature = "std" ) ) ) ]
3
1
#[ macro_export]
4
2
/// Create an [`IndexMap`][crate::IndexMap] from a list of key-value pairs
5
3
///
@@ -26,7 +24,8 @@ macro_rules! indexmap {
26
24
// Note: `stringify!($key)` is just here to consume the repetition,
27
25
// but we throw away that string literal during constant evaluation.
28
26
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 ( ) ) ;
30
29
$(
31
30
map. insert( $key, $value) ;
32
31
) *
@@ -35,8 +34,6 @@ macro_rules! indexmap {
35
34
} ;
36
35
}
37
36
38
- #[ cfg( feature = "std" ) ]
39
- #[ cfg_attr( docsrs, doc( cfg( feature = "std" ) ) ) ]
40
37
#[ macro_export]
41
38
/// Create an [`IndexSet`][crate::IndexSet] from a list of values
42
39
///
@@ -63,7 +60,8 @@ macro_rules! indexset {
63
60
// Note: `stringify!($value)` is just here to consume the repetition,
64
61
// but we throw away that string literal during constant evaluation.
65
62
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_and_hasher( CAP , <_>:: default ( ) ) ;
67
65
$(
68
66
set. insert( $value) ;
69
67
) *
You can’t perform that action at this time.
0 commit comments