fn check_for_duplicates<'t, T>(
    items: impl IntoIterator<Item = Cow<'t, T>>,
    error_wrapper: impl FnOnce(T) -> TransactionError,
) -> Result<(), TransactionError>
where
    T: Clone + Eq + Hash + 't,
{
    let mut hash_set = HashSet::new();

    for item in items {
        if let Some(duplicate) = hash_set.replace(item) {
            return Err(error_wrapper(duplicate.into_owned()));
        }
    }

    Ok(())
}
/// Check for duplicate items in a collection.
///
/// Each item should be wrapped by a [`Cow`] instance so that this helper function can properly
/// handle borrowed items and owned items.
///
/// If a duplicate is found, an error created by the `error_wrapper` is returned.
Check for duplicate items in a collection.
Each item should be wrapped by a [`Cow`] instance so that this helper function can properly
handle borrowed items and owned items.

If a duplicate is found, an error created by the `error_wrapper` is returned.
Check for duplicate items in a collection . Each item should be wrapped by a [ ` Cow ` ] instance so that this helper function can properly handle borrowed items and owned items . If a duplicate is found an error created by the ` error_wrapper ` is returned .
fn check_for_duplicates<'t, T>(
    items: impl IntoIterator<Item = Cow<'t, T>>,
    error_wrapper: impl FnOnce(T) -> TransactionError,
) -> Result<(), TransactionError>
where
    T: Clone + Eq + Hash + 't,
{
    let mut hash_set = HashSet::new();
    for item in items {
        if let Some(duplicate) = hash_set.replace(item) {
            return Err(error_wrapper(duplicate.into_owned()));
        }
    }
    Ok(())
}
fn check_for_duplicates < ' t , T > ( items : impl IntoIterator < Item = Cow < ' t , T > > , error_wrapper : impl FnOnce ( T ) -> TransactionError , ) -> Result < ( ) , TransactionError > where T : Clone + Eq + Hash + ' t , { let mut hash_set = HashSet :: new ( ) ; for item in items { if let Some ( duplicate ) = hash_set . replace ( item ) { return Err ( error_wrapper ( duplicate . into_owned ( ) ) ) ; } } Ok ( ( ) ) }
Check for duplicate items in a collection.
Check for duplicate items in a collection .
items
impl IntoIterator<Item = Cow<'t, T>>
error_wrapper
impl FnOnce(T) -> TransactionError