Skip to content

Commit

Permalink
Use owned array iterators in examples
Browse files Browse the repository at this point in the history
  • Loading branch information
yotamofek committed Mar 3, 2024
1 parent 274c7bb commit 9799f3c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ pub enum DefaultHashBuilder {}
/// use hashbrown::HashMap;
///
/// let timber_resources: HashMap<&str, i32> = [("Norway", 100), ("Denmark", 50), ("Iceland", 10)]
/// .iter().cloned().collect();
/// .into_iter().collect();
/// // use the values stored in map
/// ```
pub struct HashMap<K, V, S = DefaultHashBuilder, A: Allocator = Global> {
Expand Down
36 changes: 18 additions & 18 deletions src/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ use crate::raw::{Allocator, Global, RawExtractIf};
/// use hashbrown::HashSet;
///
/// let viking_names: HashSet<&'static str> =
/// [ "Einar", "Olaf", "Harald" ].iter().cloned().collect();
/// [ "Einar", "Olaf", "Harald" ].into_iter().collect();
/// // use the values stored in the set
/// ```
///
Expand Down Expand Up @@ -335,7 +335,7 @@ impl<T, S, A: Allocator> HashSet<T, S, A> {
/// ```
/// use hashbrown::HashSet;
///
/// let mut set: HashSet<_> = [1, 2, 3].iter().cloned().collect();
/// let mut set: HashSet<_> = [1, 2, 3].into_iter().collect();
/// assert!(!set.is_empty());
///
/// // print 1, 2, 3 in an arbitrary order
Expand All @@ -362,7 +362,7 @@ impl<T, S, A: Allocator> HashSet<T, S, A> {
/// use hashbrown::HashSet;
///
/// let xs = [1,2,3,4,5,6];
/// let mut set: HashSet<i32> = xs.iter().cloned().collect();
/// let mut set: HashSet<i32> = xs.into_iter().collect();
/// set.retain(|&k| k % 2 == 0);
/// assert_eq!(set.len(), 3);
/// ```
Expand Down Expand Up @@ -724,8 +724,8 @@ where
///
/// ```
/// use hashbrown::HashSet;
/// let a: HashSet<_> = [1, 2, 3].iter().cloned().collect();
/// let b: HashSet<_> = [4, 2, 3, 4].iter().cloned().collect();
/// let a: HashSet<_> = [1, 2, 3].into_iter().collect();
/// let b: HashSet<_> = [4, 2, 3, 4].into_iter().collect();
///
/// // Can be seen as `a - b`.
/// for x in a.difference(&b) {
Expand Down Expand Up @@ -755,8 +755,8 @@ where
///
/// ```
/// use hashbrown::HashSet;
/// let a: HashSet<_> = [1, 2, 3].iter().cloned().collect();
/// let b: HashSet<_> = [4, 2, 3, 4].iter().cloned().collect();
/// let a: HashSet<_> = [1, 2, 3].into_iter().collect();
/// let b: HashSet<_> = [4, 2, 3, 4].into_iter().collect();
///
/// // Print 1, 4 in arbitrary order.
/// for x in a.symmetric_difference(&b) {
Expand All @@ -783,8 +783,8 @@ where
///
/// ```
/// use hashbrown::HashSet;
/// let a: HashSet<_> = [1, 2, 3].iter().cloned().collect();
/// let b: HashSet<_> = [4, 2, 3, 4].iter().cloned().collect();
/// let a: HashSet<_> = [1, 2, 3].into_iter().collect();
/// let b: HashSet<_> = [4, 2, 3, 4].into_iter().collect();
///
/// // Print 2, 3 in arbitrary order.
/// for x in a.intersection(&b) {
Expand Down Expand Up @@ -814,8 +814,8 @@ where
///
/// ```
/// use hashbrown::HashSet;
/// let a: HashSet<_> = [1, 2, 3].iter().cloned().collect();
/// let b: HashSet<_> = [4, 2, 3, 4].iter().cloned().collect();
/// let a: HashSet<_> = [1, 2, 3].into_iter().collect();
/// let b: HashSet<_> = [4, 2, 3, 4].into_iter().collect();
///
/// // Print 1, 2, 3, 4 in arbitrary order.
/// for x in a.union(&b) {
Expand Down Expand Up @@ -850,7 +850,7 @@ where
/// ```
/// use hashbrown::HashSet;
///
/// let set: HashSet<_> = [1, 2, 3].iter().cloned().collect();
/// let set: HashSet<_> = [1, 2, 3].into_iter().collect();
/// assert_eq!(set.contains(&1), true);
/// assert_eq!(set.contains(&4), false);
/// ```
Expand All @@ -876,7 +876,7 @@ where
/// ```
/// use hashbrown::HashSet;
///
/// let set: HashSet<_> = [1, 2, 3].iter().cloned().collect();
/// let set: HashSet<_> = [1, 2, 3].into_iter().collect();
/// assert_eq!(set.get(&2), Some(&2));
/// assert_eq!(set.get(&4), None);
/// ```
Expand All @@ -903,7 +903,7 @@ where
/// ```
/// use hashbrown::HashSet;
///
/// let mut set: HashSet<_> = [1, 2, 3].iter().cloned().collect();
/// let mut set: HashSet<_> = [1, 2, 3].into_iter().collect();
/// assert_eq!(set.len(), 3);
/// assert_eq!(set.get_or_insert(2), &2);
/// assert_eq!(set.get_or_insert(100), &100);
Expand Down Expand Up @@ -1034,7 +1034,7 @@ where
/// ```
/// use hashbrown::HashSet;
///
/// let a: HashSet<_> = [1, 2, 3].iter().cloned().collect();
/// let a: HashSet<_> = [1, 2, 3].into_iter().collect();
/// let mut b = HashSet::new();
///
/// assert_eq!(a.is_disjoint(&b), true);
Expand All @@ -1055,7 +1055,7 @@ where
/// ```
/// use hashbrown::HashSet;
///
/// let sup: HashSet<_> = [1, 2, 3].iter().cloned().collect();
/// let sup: HashSet<_> = [1, 2, 3].into_iter().collect();
/// let mut set = HashSet::new();
///
/// assert_eq!(set.is_subset(&sup), true);
Expand All @@ -1076,7 +1076,7 @@ where
/// ```
/// use hashbrown::HashSet;
///
/// let sub: HashSet<_> = [1, 2].iter().cloned().collect();
/// let sub: HashSet<_> = [1, 2].into_iter().collect();
/// let mut set = HashSet::new();
///
/// assert_eq!(set.is_superset(&sub), false);
Expand Down Expand Up @@ -1205,7 +1205,7 @@ where
/// ```
/// use hashbrown::HashSet;
///
/// let mut set: HashSet<_> = [1, 2, 3].iter().cloned().collect();
/// let mut set: HashSet<_> = [1, 2, 3].into_iter().collect();
/// assert_eq!(set.take(&2), Some(2));
/// assert_eq!(set.take(&2), None);
/// ```
Expand Down

0 comments on commit 9799f3c

Please sign in to comment.