1
+ //! A fixed-capacity hash table where the iteration order is independent of the hash of the keys.
1
2
use core:: {
2
3
borrow:: Borrow ,
3
4
fmt,
@@ -18,7 +19,7 @@ use crate::Vec;
18
19
///
19
20
/// # Examples
20
21
/// ```
21
- /// use heapless::FnvIndexMap;
22
+ /// use heapless::index_map:: FnvIndexMap;
22
23
///
23
24
/// // A hash map with a capacity of 16 key-value pairs allocated on the stack
24
25
/// let mut book_reviews = FnvIndexMap::<_, _, 16>::new();
@@ -396,7 +397,7 @@ where
396
397
/// # Examples
397
398
///
398
399
/// ```
399
- /// use heapless::FnvIndexMap;
400
+ /// use heapless::index_map:: FnvIndexMap;
400
401
///
401
402
/// // A hash map with a capacity of 16 key-value pairs allocated on the stack
402
403
/// let mut book_reviews = FnvIndexMap::<_, _, 16>::new();
@@ -424,7 +425,7 @@ where
424
425
/// # Examples
425
426
///
426
427
/// ```
427
- /// use heapless::FnvIndexMap;
428
+ /// use heapless::index_map:: FnvIndexMap;
428
429
///
429
430
/// // A hash map with a capacity of 16 key-value pairs allocated on the stack
430
431
/// let mut book_reviews = FnvIndexMap::<_, _, 16>::new();
@@ -457,7 +458,7 @@ where
457
458
/// # Examples
458
459
///
459
460
/// ```
460
- /// use heapless::FnvIndexMap;
461
+ /// use heapless::index_map:: FnvIndexMap;
461
462
///
462
463
/// // A hash map with a capacity of 16 key-value pairs allocated on the stack
463
464
/// let mut book_reviews = FnvIndexMap::<_, _, 16>::new();
@@ -483,7 +484,7 @@ where
483
484
/// # Examples
484
485
///
485
486
/// ```
486
- /// use heapless::FnvIndexMap;
487
+ /// use heapless::index_map:: FnvIndexMap;
487
488
///
488
489
/// // A hash map with a capacity of 16 key-value pairs allocated on the stack
489
490
/// let mut book_reviews = FnvIndexMap::<&str, &str, 16>::new();
@@ -507,7 +508,7 @@ where
507
508
/// # Examples
508
509
///
509
510
/// ```
510
- /// use heapless::FnvIndexMap;
511
+ /// use heapless::index_map:: FnvIndexMap;
511
512
///
512
513
/// // A hash map with a capacity of 16 key-value pairs allocated on the stack
513
514
/// let mut book_reviews = FnvIndexMap::<_, _, 16>::new();
@@ -544,7 +545,7 @@ where
544
545
///
545
546
/// ```
546
547
/// # fn main() {
547
- /// use heapless::FnvIndexMap;
548
+ /// use heapless::index_map:: FnvIndexMap;
548
549
///
549
550
/// let mut book_reviews = FnvIndexMap::<&str, Option<&str>, 16>::new();
550
551
///
@@ -677,7 +678,7 @@ where
677
678
/// for this example.
678
679
///
679
680
/// ```
680
- /// use heapless::FnvIndexMap;
681
+ /// use heapless::index_map:: FnvIndexMap;
681
682
///
682
683
/// // A hash map with a capacity of 16 key-value pairs allocated on the stack
683
684
/// let mut book_reviews = FnvIndexMap::<_, _, 16>::new();
@@ -750,7 +751,7 @@ impl<K, V, S, const N: usize> IndexMap<K, V, S, N> {
750
751
/// Return an iterator over the keys of the map, in insertion order
751
752
///
752
753
/// ```
753
- /// use heapless::FnvIndexMap;
754
+ /// use heapless::index_map:: FnvIndexMap;
754
755
///
755
756
/// let mut map = FnvIndexMap::<_, _, 16>::new();
756
757
/// map.insert("a", 1).unwrap();
@@ -770,7 +771,7 @@ impl<K, V, S, const N: usize> IndexMap<K, V, S, N> {
770
771
/// Return an iterator over the values of the map, in insertion order
771
772
///
772
773
/// ```
773
- /// use heapless::FnvIndexMap;
774
+ /// use heapless::index_map:: FnvIndexMap;
774
775
///
775
776
/// let mut map = FnvIndexMap::<_, _, 16>::new();
776
777
/// map.insert("a", 1).unwrap();
@@ -790,7 +791,7 @@ impl<K, V, S, const N: usize> IndexMap<K, V, S, N> {
790
791
/// Return an iterator over mutable references to the the values of the map, in insertion order
791
792
///
792
793
/// ```
793
- /// use heapless::FnvIndexMap;
794
+ /// use heapless::index_map:: FnvIndexMap;
794
795
///
795
796
/// let mut map = FnvIndexMap::<_, _, 16>::new();
796
797
/// map.insert("a", 1).unwrap();
@@ -814,7 +815,7 @@ impl<K, V, S, const N: usize> IndexMap<K, V, S, N> {
814
815
/// Return an iterator over the key-value pairs of the map, in insertion order
815
816
///
816
817
/// ```
817
- /// use heapless::FnvIndexMap;
818
+ /// use heapless::index_map:: FnvIndexMap;
818
819
///
819
820
/// let mut map = FnvIndexMap::<_, _, 16>::new();
820
821
/// map.insert("a", 1).unwrap();
@@ -834,7 +835,7 @@ impl<K, V, S, const N: usize> IndexMap<K, V, S, N> {
834
835
/// Return an iterator over the key-value pairs of the map, in insertion order
835
836
///
836
837
/// ```
837
- /// use heapless::FnvIndexMap;
838
+ /// use heapless::index_map:: FnvIndexMap;
838
839
///
839
840
/// let mut map = FnvIndexMap::<_, _, 16>::new();
840
841
/// map.insert("a", 1).unwrap();
@@ -900,7 +901,7 @@ impl<K, V, S, const N: usize> IndexMap<K, V, S, N> {
900
901
/// Computes in *O*(1) time.
901
902
///
902
903
/// ```
903
- /// use heapless::FnvIndexMap;
904
+ /// use heapless::index_map:: FnvIndexMap;
904
905
///
905
906
/// let mut a = FnvIndexMap::<_, _, 16>::new();
906
907
/// assert_eq!(a.len(), 0);
@@ -916,7 +917,7 @@ impl<K, V, S, const N: usize> IndexMap<K, V, S, N> {
916
917
/// Computes in *O*(1) time.
917
918
///
918
919
/// ```
919
- /// use heapless::FnvIndexMap;
920
+ /// use heapless::index_map:: FnvIndexMap;
920
921
///
921
922
/// let mut a = FnvIndexMap::<_, _, 16>::new();
922
923
/// assert!(a.is_empty());
@@ -932,7 +933,7 @@ impl<K, V, S, const N: usize> IndexMap<K, V, S, N> {
932
933
/// Computes in *O*(1) time.
933
934
///
934
935
/// ```
935
- /// use heapless::FnvIndexMap;
936
+ /// use heapless::index_map:: FnvIndexMap;
936
937
///
937
938
/// let mut a = FnvIndexMap::<_, _, 4>::new();
938
939
/// assert!(!a.is_full());
@@ -951,7 +952,7 @@ impl<K, V, S, const N: usize> IndexMap<K, V, S, N> {
951
952
/// Computes in *O*(n) time.
952
953
///
953
954
/// ```
954
- /// use heapless::FnvIndexMap;
955
+ /// use heapless::index_map:: FnvIndexMap;
955
956
///
956
957
/// let mut a = FnvIndexMap::<_, _, 16>::new();
957
958
/// a.insert(1, "a");
@@ -974,8 +975,8 @@ where
974
975
/* Public API */
975
976
/// Returns an entry for the corresponding key
976
977
/// ```
977
- /// use heapless::Entry;
978
- /// use heapless::FnvIndexMap;
978
+ /// use heapless::index_map:: Entry;
979
+ /// use heapless::index_map:: FnvIndexMap;
979
980
/// let mut map = FnvIndexMap::<_, _, 16>::new();
980
981
/// if let Entry::Vacant(v) = map.entry("a") {
981
982
/// v.insert(1).unwrap();
@@ -1013,7 +1014,7 @@ where
1013
1014
/// Computes in *O*(1) time (average).
1014
1015
///
1015
1016
/// ```
1016
- /// use heapless::FnvIndexMap;
1017
+ /// use heapless::index_map:: FnvIndexMap;
1017
1018
///
1018
1019
/// let mut map = FnvIndexMap::<_, _, 16>::new();
1019
1020
/// map.insert(1, "a").unwrap();
@@ -1039,7 +1040,7 @@ where
1039
1040
/// # Examples
1040
1041
///
1041
1042
/// ```
1042
- /// use heapless::FnvIndexMap;
1043
+ /// use heapless::index_map:: FnvIndexMap;
1043
1044
///
1044
1045
/// let mut map = FnvIndexMap::<_, _, 8>::new();
1045
1046
/// map.insert(1, "a").unwrap();
@@ -1064,7 +1065,7 @@ where
1064
1065
/// # Examples
1065
1066
///
1066
1067
/// ```
1067
- /// use heapless::FnvIndexMap;
1068
+ /// use heapless::index_map:: FnvIndexMap;
1068
1069
///
1069
1070
/// let mut map = FnvIndexMap::<_, _, 8>::new();
1070
1071
/// map.insert(1, "a").unwrap();
@@ -1092,7 +1093,7 @@ where
1092
1093
/// # Examples
1093
1094
///
1094
1095
/// ```
1095
- /// use heapless::FnvIndexMap;
1096
+ /// use heapless::index_map:: FnvIndexMap;
1096
1097
///
1097
1098
/// let mut map = FnvIndexMap::<_, _, 16>::new();
1098
1099
/// map.insert(1, "a").unwrap();
@@ -1113,7 +1114,7 @@ where
1113
1114
/// # Examples
1114
1115
///
1115
1116
/// ```
1116
- /// use heapless::FnvIndexMap;
1117
+ /// use heapless::index_map:: FnvIndexMap;
1117
1118
///
1118
1119
/// let mut map = FnvIndexMap::<_, _, 8>::new();
1119
1120
/// map.insert(1, "a").unwrap();
@@ -1139,7 +1140,7 @@ where
1139
1140
/// # Examples
1140
1141
///
1141
1142
/// ```
1142
- /// use heapless::FnvIndexMap;
1143
+ /// use heapless::index_map:: FnvIndexMap;
1143
1144
///
1144
1145
/// let mut map = FnvIndexMap::<_, _, 8>::new();
1145
1146
/// map.insert(1, "a").unwrap();
@@ -1173,7 +1174,7 @@ where
1173
1174
/// # Examples
1174
1175
///
1175
1176
/// ```
1176
- /// use heapless::FnvIndexMap;
1177
+ /// use heapless::index_map:: FnvIndexMap;
1177
1178
///
1178
1179
/// let mut map = FnvIndexMap::<_, _, 8>::new();
1179
1180
/// assert_eq!(map.insert(37, "a"), Ok(None));
@@ -1198,7 +1199,7 @@ where
1198
1199
/// # Examples
1199
1200
///
1200
1201
/// ```
1201
- /// use heapless::FnvIndexMap;
1202
+ /// use heapless::index_map:: FnvIndexMap;
1202
1203
///
1203
1204
/// let mut map = FnvIndexMap::<_, _, 8>::new();
1204
1205
/// map.insert(1, "a").unwrap();
@@ -1249,7 +1250,7 @@ where
1249
1250
/// # Examples
1250
1251
///
1251
1252
/// ```
1252
- /// use heapless::FnvIndexMap;
1253
+ /// use heapless::index_map:: FnvIndexMap;
1253
1254
///
1254
1255
/// let mut map = FnvIndexMap::<_, _, 8>::new();
1255
1256
/// map.insert(3, "a").unwrap();
@@ -1415,6 +1416,23 @@ where
1415
1416
}
1416
1417
}
1417
1418
1419
+ /// An owning iterator over the entries of an `IndexMap`.
1420
+ ///
1421
+ /// This `struct` is created by the [`into_iter`] method on [`IndexMap`]
1422
+ /// (provided by the [`IntoIterator`] trait). See its documentation for more.
1423
+ ///
1424
+ /// [`into_iter`]: IntoIterator::into_iter
1425
+ ///
1426
+ /// # Example
1427
+ ///
1428
+ /// ```
1429
+ /// use heapless::index_map::FnvIndexMap;
1430
+ ///
1431
+ /// let mut map = FnvIndexMap::<_, _, 16>::new();
1432
+ /// map.insert("a", 1).unwrap();
1433
+ ///
1434
+ /// let iter = map.into_iter();
1435
+ /// ```
1418
1436
#[ derive( Clone ) ]
1419
1437
pub struct IntoIter < K , V , const N : usize > {
1420
1438
entries : Vec < Bucket < K , V > , N , usize > ,
0 commit comments