Struct Intersection

#[must_use = "this returns the intersection as an iterator, without modifying either input set"]
pub struct Intersection<'a, T: 'a, S: 'a, A: Allocator = Global> { pub(in ::collections::hash::set) iter: Iter<'a, T>, pub(in ::collections::hash::set) other: &'a HashSet<T, S, A> }

A lazy iterator producing elements in the intersection of HashSets.

This struct is created by the intersection method on HashSet. See its documentation for more.

Examples

use std::collections::HashSet;

let a = HashSet::from([1, 2, 3]);
let b = HashSet::from([4, 2, 3, 4]);

let mut intersection = a.intersection(&b);

Fields

iter: Iter<'a, T>
other: &'a HashSet<T, S, A>

Trait Implementations

impl<'a, T, S, A> Iterator for Intersection<'a, T, S, A> where T: Eq + Hash, S: BuildHasher, A: Allocator,

type Item = &'a T;
fn next(&mut self) -> Option<&'a T>
fn size_hint(&self) -> (usize, Option<usize>)
fn fold<B, F>(self, init: B, f: F) -> B
where
    Self: Sized,
    F: FnMut(B, Self::Item) -> B,

impl<T, S, A> Debug for Intersection<'_, T, S, A> where T: Debug + Eq + Hash, S: BuildHasher, A: Allocator,

fn fmt(&self, f: &mut Formatter<'_>) -> Result

impl<T, S, A> FusedIterator for Intersection<'_, T, S, A> where T: Eq + Hash, S: BuildHasher, A: Allocator,

impl<T, S, A: Allocator> Clone for Intersection<'_, T, S, A>

fn clone(&self) -> Self

Auto Trait Implementations

impl<'a, T, S, A> Freeze for Intersection<'a, T, S, A> where Iter<'a, T>: Freeze, &'a HashSet<T, S, A>: Freeze,

impl<'a, T, S, A> RefUnwindSafe for Intersection<'a, T, S, A> where Iter<'a, T>: RefUnwindSafe, &'a HashSet<T, S, A>: RefUnwindSafe,

impl<'a, T, S, A> Send for Intersection<'a, T, S, A> where Iter<'a, T>: Send, &'a HashSet<T, S, A>: Send,

impl<'a, T, S, A> Sync for Intersection<'a, T, S, A> where Iter<'a, T>: Sync, &'a HashSet<T, S, A>: Sync,

impl<'a, T, S, A> Unpin for Intersection<'a, T, S, A> where Iter<'a, T>: Unpin, &'a HashSet<T, S, A>: Unpin,

impl<'a, T, S, A> UnsafeUnpin for Intersection<'a, T, S, A> where Iter<'a, T>: UnsafeUnpin, &'a HashSet<T, S, A>: UnsafeUnpin,

impl<'a, T, S, A> UnwindSafe for Intersection<'a, T, S, A> where Iter<'a, T>: UnwindSafe, &'a HashSet<T, S, A>: UnwindSafe,

Blanket Implementations

impl<I> IntoIterator for Intersection<'a, T, S, A> where I: Iterator,

type Item = <I as Iterator>::Item;
type IntoIter = I;
fn into_iter(self) -> I

impl<T> Any for Intersection<'a, T, S, A> where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for Intersection<'a, T, S, A> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for Intersection<'a, T, S, A> where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> CloneToUninit for Intersection<'a, T, S, A> where T: Clone,

unsafe fn clone_to_uninit(&self, dest: *mut u8)

impl<T> From<T> for Intersection<'a, T, S, A>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> SizeHint for Intersection<'a, T, S, A> where T: ?Sized,

fn lower_bound(&self) -> usize
fn upper_bound(&self) -> Option<usize>

impl<T> SizedTypeProperties for Intersection<'a, T, S, A>

impl<T> ToOwned for Intersection<'a, T, S, A> where T: Clone,

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T, U> Into<U> for Intersection<'a, T, S, A> where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for Intersection<'a, T, S, A> where U: Into<T>,

type Error = Infallible;
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto<U> for Intersection<'a, T, S, A> where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>