Last active
October 30, 2017 19:21
-
-
Save rrichardson/48dc934fe193d2d81baca05958dd5abd 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,T> Set<K,T> | |
where K : Serialize + DeserializeOwned + Ord + Clone, | |
T : Serialize + DeserializeOwned + Ord + Clone, | |
{ | |
pub fn new(db: Arc<DB>, cf: ColumnFamily) -> Set<K,T> { | |
Set { db, cf, p1: PhantomData, p2: PhantomData } | |
} | |
pub fn create<I>(&self, key: &K, values: I, ttl: Option<i64>) -> Result<(), Error> | |
where for<'a> &'a I: IntoIterator<Item=&'a T> { | |
let kbuf = serialize(&key, Infinite)?; | |
let mut vbuf : Vec<u8> = Vec::with_capacity(32); | |
set_ttl(&mut vbuf, ttl)?; | |
let val : BTreeSet<&T> = values.into_iter().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 mut stuff : Vec<String> = | |
LOREM2.with(|cell| { | |
let mut chain1 = cell.borrow_mut(); | |
chain1.iter().take(100).map(String::from).collect() }); | |
tbl.create(&key, &stuff, None).unwrap(); | |
error[E0277]: the trait bound `for<'a> &'a &_: std::iter::Iterator` is not satisfied | |
--> src/lib.rs:453:13 | |
| | |
453 | tbl.create(&key, &stuff.iter().map(|v| &v).collect(), None).unwrap(); | |
| ^^^^^^ `&'a &_` is not an iterator; maybe try calling `.iter()` or a similar method | |
| | |
= help: the trait `for<'a> std::iter::Iterator` is not implemented for `&'a &_` | |
= note: required because of the requirements on the impl of `for<'a> std::iter::IntoIterator` for `&'a &_` |
Author
rrichardson
commented
Oct 30, 2017
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment