Skip to content

Commit 7275c51

Browse files
committed
Rename indexmap to index_map and only re-export IndexMap
1 parent fb62d12 commit 7275c51

File tree

3 files changed

+50
-36
lines changed

3 files changed

+50
-36
lines changed

src/indexmap.rs renamed to src/index_map.rs

Lines changed: 46 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//! A fixed-capacity hash table where the iteration order is independent of the hash of the keys.
12
use core::{
23
borrow::Borrow,
34
fmt,
@@ -18,7 +19,7 @@ use crate::Vec;
1819
///
1920
/// # Examples
2021
/// ```
21-
/// use heapless::FnvIndexMap;
22+
/// use heapless::index_map::FnvIndexMap;
2223
///
2324
/// // A hash map with a capacity of 16 key-value pairs allocated on the stack
2425
/// let mut book_reviews = FnvIndexMap::<_, _, 16>::new();
@@ -396,7 +397,7 @@ where
396397
/// # Examples
397398
///
398399
/// ```
399-
/// use heapless::FnvIndexMap;
400+
/// use heapless::index_map::FnvIndexMap;
400401
///
401402
/// // A hash map with a capacity of 16 key-value pairs allocated on the stack
402403
/// let mut book_reviews = FnvIndexMap::<_, _, 16>::new();
@@ -424,7 +425,7 @@ where
424425
/// # Examples
425426
///
426427
/// ```
427-
/// use heapless::FnvIndexMap;
428+
/// use heapless::index_map::FnvIndexMap;
428429
///
429430
/// // A hash map with a capacity of 16 key-value pairs allocated on the stack
430431
/// let mut book_reviews = FnvIndexMap::<_, _, 16>::new();
@@ -457,7 +458,7 @@ where
457458
/// # Examples
458459
///
459460
/// ```
460-
/// use heapless::FnvIndexMap;
461+
/// use heapless::index_map::FnvIndexMap;
461462
///
462463
/// // A hash map with a capacity of 16 key-value pairs allocated on the stack
463464
/// let mut book_reviews = FnvIndexMap::<_, _, 16>::new();
@@ -483,7 +484,7 @@ where
483484
/// # Examples
484485
///
485486
/// ```
486-
/// use heapless::FnvIndexMap;
487+
/// use heapless::index_map::FnvIndexMap;
487488
///
488489
/// // A hash map with a capacity of 16 key-value pairs allocated on the stack
489490
/// let mut book_reviews = FnvIndexMap::<&str, &str, 16>::new();
@@ -507,7 +508,7 @@ where
507508
/// # Examples
508509
///
509510
/// ```
510-
/// use heapless::FnvIndexMap;
511+
/// use heapless::index_map::FnvIndexMap;
511512
///
512513
/// // A hash map with a capacity of 16 key-value pairs allocated on the stack
513514
/// let mut book_reviews = FnvIndexMap::<_, _, 16>::new();
@@ -544,7 +545,7 @@ where
544545
///
545546
/// ```
546547
/// # fn main() {
547-
/// use heapless::FnvIndexMap;
548+
/// use heapless::index_map::FnvIndexMap;
548549
///
549550
/// let mut book_reviews = FnvIndexMap::<&str, Option<&str>, 16>::new();
550551
///
@@ -677,7 +678,7 @@ where
677678
/// for this example.
678679
///
679680
/// ```
680-
/// use heapless::FnvIndexMap;
681+
/// use heapless::index_map::FnvIndexMap;
681682
///
682683
/// // A hash map with a capacity of 16 key-value pairs allocated on the stack
683684
/// let mut book_reviews = FnvIndexMap::<_, _, 16>::new();
@@ -750,7 +751,7 @@ impl<K, V, S, const N: usize> IndexMap<K, V, S, N> {
750751
/// Return an iterator over the keys of the map, in insertion order
751752
///
752753
/// ```
753-
/// use heapless::FnvIndexMap;
754+
/// use heapless::index_map::FnvIndexMap;
754755
///
755756
/// let mut map = FnvIndexMap::<_, _, 16>::new();
756757
/// map.insert("a", 1).unwrap();
@@ -770,7 +771,7 @@ impl<K, V, S, const N: usize> IndexMap<K, V, S, N> {
770771
/// Return an iterator over the values of the map, in insertion order
771772
///
772773
/// ```
773-
/// use heapless::FnvIndexMap;
774+
/// use heapless::index_map::FnvIndexMap;
774775
///
775776
/// let mut map = FnvIndexMap::<_, _, 16>::new();
776777
/// map.insert("a", 1).unwrap();
@@ -790,7 +791,7 @@ impl<K, V, S, const N: usize> IndexMap<K, V, S, N> {
790791
/// Return an iterator over mutable references to the the values of the map, in insertion order
791792
///
792793
/// ```
793-
/// use heapless::FnvIndexMap;
794+
/// use heapless::index_map::FnvIndexMap;
794795
///
795796
/// let mut map = FnvIndexMap::<_, _, 16>::new();
796797
/// map.insert("a", 1).unwrap();
@@ -814,7 +815,7 @@ impl<K, V, S, const N: usize> IndexMap<K, V, S, N> {
814815
/// Return an iterator over the key-value pairs of the map, in insertion order
815816
///
816817
/// ```
817-
/// use heapless::FnvIndexMap;
818+
/// use heapless::index_map::FnvIndexMap;
818819
///
819820
/// let mut map = FnvIndexMap::<_, _, 16>::new();
820821
/// map.insert("a", 1).unwrap();
@@ -834,7 +835,7 @@ impl<K, V, S, const N: usize> IndexMap<K, V, S, N> {
834835
/// Return an iterator over the key-value pairs of the map, in insertion order
835836
///
836837
/// ```
837-
/// use heapless::FnvIndexMap;
838+
/// use heapless::index_map::FnvIndexMap;
838839
///
839840
/// let mut map = FnvIndexMap::<_, _, 16>::new();
840841
/// map.insert("a", 1).unwrap();
@@ -900,7 +901,7 @@ impl<K, V, S, const N: usize> IndexMap<K, V, S, N> {
900901
/// Computes in *O*(1) time.
901902
///
902903
/// ```
903-
/// use heapless::FnvIndexMap;
904+
/// use heapless::index_map::FnvIndexMap;
904905
///
905906
/// let mut a = FnvIndexMap::<_, _, 16>::new();
906907
/// assert_eq!(a.len(), 0);
@@ -916,7 +917,7 @@ impl<K, V, S, const N: usize> IndexMap<K, V, S, N> {
916917
/// Computes in *O*(1) time.
917918
///
918919
/// ```
919-
/// use heapless::FnvIndexMap;
920+
/// use heapless::index_map::FnvIndexMap;
920921
///
921922
/// let mut a = FnvIndexMap::<_, _, 16>::new();
922923
/// assert!(a.is_empty());
@@ -932,7 +933,7 @@ impl<K, V, S, const N: usize> IndexMap<K, V, S, N> {
932933
/// Computes in *O*(1) time.
933934
///
934935
/// ```
935-
/// use heapless::FnvIndexMap;
936+
/// use heapless::index_map::FnvIndexMap;
936937
///
937938
/// let mut a = FnvIndexMap::<_, _, 4>::new();
938939
/// assert!(!a.is_full());
@@ -951,7 +952,7 @@ impl<K, V, S, const N: usize> IndexMap<K, V, S, N> {
951952
/// Computes in *O*(n) time.
952953
///
953954
/// ```
954-
/// use heapless::FnvIndexMap;
955+
/// use heapless::index_map::FnvIndexMap;
955956
///
956957
/// let mut a = FnvIndexMap::<_, _, 16>::new();
957958
/// a.insert(1, "a");
@@ -974,8 +975,8 @@ where
974975
/* Public API */
975976
/// Returns an entry for the corresponding key
976977
/// ```
977-
/// use heapless::Entry;
978-
/// use heapless::FnvIndexMap;
978+
/// use heapless::index_map::Entry;
979+
/// use heapless::index_map::FnvIndexMap;
979980
/// let mut map = FnvIndexMap::<_, _, 16>::new();
980981
/// if let Entry::Vacant(v) = map.entry("a") {
981982
/// v.insert(1).unwrap();
@@ -1013,7 +1014,7 @@ where
10131014
/// Computes in *O*(1) time (average).
10141015
///
10151016
/// ```
1016-
/// use heapless::FnvIndexMap;
1017+
/// use heapless::index_map::FnvIndexMap;
10171018
///
10181019
/// let mut map = FnvIndexMap::<_, _, 16>::new();
10191020
/// map.insert(1, "a").unwrap();
@@ -1039,7 +1040,7 @@ where
10391040
/// # Examples
10401041
///
10411042
/// ```
1042-
/// use heapless::FnvIndexMap;
1043+
/// use heapless::index_map::FnvIndexMap;
10431044
///
10441045
/// let mut map = FnvIndexMap::<_, _, 8>::new();
10451046
/// map.insert(1, "a").unwrap();
@@ -1064,7 +1065,7 @@ where
10641065
/// # Examples
10651066
///
10661067
/// ```
1067-
/// use heapless::FnvIndexMap;
1068+
/// use heapless::index_map::FnvIndexMap;
10681069
///
10691070
/// let mut map = FnvIndexMap::<_, _, 8>::new();
10701071
/// map.insert(1, "a").unwrap();
@@ -1092,7 +1093,7 @@ where
10921093
/// # Examples
10931094
///
10941095
/// ```
1095-
/// use heapless::FnvIndexMap;
1096+
/// use heapless::index_map::FnvIndexMap;
10961097
///
10971098
/// let mut map = FnvIndexMap::<_, _, 16>::new();
10981099
/// map.insert(1, "a").unwrap();
@@ -1113,7 +1114,7 @@ where
11131114
/// # Examples
11141115
///
11151116
/// ```
1116-
/// use heapless::FnvIndexMap;
1117+
/// use heapless::index_map::FnvIndexMap;
11171118
///
11181119
/// let mut map = FnvIndexMap::<_, _, 8>::new();
11191120
/// map.insert(1, "a").unwrap();
@@ -1139,7 +1140,7 @@ where
11391140
/// # Examples
11401141
///
11411142
/// ```
1142-
/// use heapless::FnvIndexMap;
1143+
/// use heapless::index_map::FnvIndexMap;
11431144
///
11441145
/// let mut map = FnvIndexMap::<_, _, 8>::new();
11451146
/// map.insert(1, "a").unwrap();
@@ -1173,7 +1174,7 @@ where
11731174
/// # Examples
11741175
///
11751176
/// ```
1176-
/// use heapless::FnvIndexMap;
1177+
/// use heapless::index_map::FnvIndexMap;
11771178
///
11781179
/// let mut map = FnvIndexMap::<_, _, 8>::new();
11791180
/// assert_eq!(map.insert(37, "a"), Ok(None));
@@ -1198,7 +1199,7 @@ where
11981199
/// # Examples
11991200
///
12001201
/// ```
1201-
/// use heapless::FnvIndexMap;
1202+
/// use heapless::index_map::FnvIndexMap;
12021203
///
12031204
/// let mut map = FnvIndexMap::<_, _, 8>::new();
12041205
/// map.insert(1, "a").unwrap();
@@ -1249,7 +1250,7 @@ where
12491250
/// # Examples
12501251
///
12511252
/// ```
1252-
/// use heapless::FnvIndexMap;
1253+
/// use heapless::index_map::FnvIndexMap;
12531254
///
12541255
/// let mut map = FnvIndexMap::<_, _, 8>::new();
12551256
/// map.insert(3, "a").unwrap();
@@ -1415,6 +1416,23 @@ where
14151416
}
14161417
}
14171418

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+
/// ```
14181436
#[derive(Clone)]
14191437
pub struct IntoIter<K, V, const N: usize> {
14201438
entries: Vec<Bucket<K, V>, N, usize>,

src/indexset.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use core::{
66

77
use hash32::{BuildHasherDefault, FnvHasher};
88

9-
use crate::indexmap::{self, IndexMap};
9+
use crate::index_map::{self, IndexMap};
1010

1111
/// An [`IndexSet`] using the default FNV hasher.
1212
///
@@ -610,7 +610,7 @@ where
610610
/// This `struct` is created by the [`iter`](IndexSet::iter) method on [`IndexSet`]. See its
611611
/// documentation for more.
612612
pub struct Iter<'a, T> {
613-
iter: indexmap::Iter<'a, T, ()>,
613+
iter: index_map::Iter<'a, T, ()>,
614614
}
615615

616616
impl<'a, T> Iterator for Iter<'a, T> {

src/lib.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,7 @@ extern crate alloc;
159159
pub use binary_heap::BinaryHeap;
160160
pub use deque::Deque;
161161
pub use histbuf::{HistoryBuffer, OldestOrdered};
162-
pub use indexmap::{
163-
Bucket, Entry, FnvIndexMap, IndexMap, Iter as IndexMapIter, IterMut as IndexMapIterMut,
164-
Keys as IndexMapKeys, OccupiedEntry, Pos, VacantEntry, Values as IndexMapValues,
165-
ValuesMut as IndexMapValuesMut,
166-
};
162+
pub use index_map::IndexMap;
167163
pub use indexset::{FnvIndexSet, IndexSet, Iter as IndexSetIter};
168164
pub use len_type::LenType;
169165
pub use linear_map::LinearMap;
@@ -177,7 +173,7 @@ mod test_helpers;
177173

178174
pub mod deque;
179175
pub mod histbuf;
180-
mod indexmap;
176+
pub mod index_map;
181177
mod indexset;
182178
mod len_type;
183179
pub mod linear_map;

0 commit comments

Comments
 (0)