Last active
October 30, 2017 17:49
-
-
Save rrichardson/e6910752c970961505b29d5906330bca to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
impl<K,U,V> Map<K,U,V> | |
where K: Serialize + DeserializeOwned + Ord + Clone, | |
U: Serialize + DeserializeOwned + Ord + Clone, | |
V: Serialize + DeserializeOwned + Clone, | |
{ | |
pub fn new(db: Arc<DB>, cf: ColumnFamily) -> Map<K,U,V> { | |
Map { db, cf, p1: PhantomData, p2: PhantomData, p3: PhantomData } | |
} | |
pub fn create<'a, I>(&self, key: &K, values: I, ttl: Option<i64>) -> Result<(), Error> | |
where I: Iterator<Item=(U,V)> | |
{ | |
let kbuf = serialize(&key, Infinite)?; | |
let mut vbuf : Vec<u8> = Vec::with_capacity(32); | |
set_ttl(&mut vbuf, ttl)?; | |
let val : BTreeMap<U,V> = values.collect(); | |
serialize_into(&mut vbuf, &val, Infinite).map_err(Error::from)?; | |
self.db.put_cf(self.cf, kbuf.as_slice(), vbuf.as_slice()).map_err( | |
Error::from, | |
) | |
} | |
} | |
... | |
let tbl = db.get_map::<String, String, String>("latin").unwrap(); | |
let entries2 : Vec<(String, String)> = keys2.into_iter().zip(vals2.into_iter()).collect(); | |
tbl.create(&key1, entries1.iter(), None).unwrap(); | |
/// | |
error[E0271]: type mismatch resolving `<std::slice::Iter<'_, (std::string::String, std::string::String)> as std::iter::Iterator>::Item == (std::string::String, std::string::String)` | |
--> src/lib.rs:573:13 | |
| | |
573 | tbl.create(&key1, entries1.iter(), None).unwrap(); | |
| ^^^^^^ expected reference, found tuple | |
| | |
= note: expected type `&(std::string::String, std::string::String)` | |
found type `(std::string::String, std::string::String)` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment