fix: membership deserializing

This commit is contained in:
Timo Kösters 2021-04-09 21:38:16 +02:00
parent 51aa6448bc
commit 84f4ce73e5
No known key found for this signature in database
GPG key ID: 24DA7517711A2BA4
9 changed files with 74 additions and 63 deletions

View file

@ -2,7 +2,6 @@ use argon2::{Config, Variant};
use cmp::Ordering;
use rand::prelude::*;
use ruma::serde::{try_from_json_map, CanonicalJsonError, CanonicalJsonObject};
use sled::IVec;
use std::{
cmp,
convert::TryInto,
@ -70,10 +69,10 @@ pub fn calculate_hash(password: &str) -> Result<String, argon2::Error> {
argon2::hash_encoded(password.as_bytes(), salt.as_bytes(), &hashing_config)
}
pub fn common_elements(
mut iterators: impl Iterator<Item = impl Iterator<Item = IVec>>,
check_order: impl Fn(&IVec, &IVec) -> Ordering,
) -> Option<impl Iterator<Item = IVec>> {
pub fn common_elements<'a>(
mut iterators: impl Iterator<Item = impl Iterator<Item = Vec<u8>>>,
check_order: impl Fn(&[u8], &[u8]) -> Ordering,
) -> Option<impl Iterator<Item = Vec<u8>>> {
let first_iterator = iterators.next()?;
let mut other_iterators = iterators.map(|i| i.peekable()).collect::<Vec<_>>();