pub fn find_duplicate<I>(iter: I) -> Option<I::Item>
where
    I: IntoIterator,
    I::Item: Clone + Eq + Hash,
{
    let mut seen = HashSet::new();
    for x in iter {
        if seen.contains(&x) {
            return Some(x);
        }

        seen.insert(x);
    }

    None
}
/// Searches for an element of the iterator which appears more than once.
///
/// If no such element exists, `find_duplicate()` returns `None`.
/// Otherwise, `find_duplicate()` returns `Some(element)`, where `element` is
/// the first one which appears more than once.
Searches for an element of the iterator which appears more than once.
If no such element exists, `find_duplicate()` returns `None`.
Searches for an element of the iterator which appears more than once . If no such element exists ` find_duplicate () ` returns ` None ` .
pub fn find_duplicate<I>(iter: I) -> Option<I::Item>
where
    I: IntoIterator,
    I::Item: Clone + Eq + Hash,
{
    let mut seen = HashSet::new();
    for x in iter {
        if seen.contains(&x) {
            return Some(x);
        }
        seen.insert(x);
    }
    None
}
pub fn find_duplicate < I > ( iter : I ) -> Option < I :: Item > where I : IntoIterator , I :: Item : Clone + Eq + Hash , { let mut seen = HashSet :: new ( ) ; for x in iter { if seen . contains ( & x ) { return Some ( x ) ; } seen . insert ( x ) ; } None }
Searches for an element of the iterator which appears more than once.
Searches for an element of the iterator which appears more than once .
iter
I
iter
I