Skip to content

Instantly share code, notes, and snippets.

@rrichardson
Created October 27, 2017 19:41
Show Gist options
  • Save rrichardson/d2b106f2d91be4ea3070e2d11a22577e to your computer and use it in GitHub Desktop.
Save rrichardson/d2b106f2d91be4ea3070e2d11a22577e to your computer and use it in GitHub Desktop.
lifetimes
pub fn create<'a, I>(&self, key: &K, values: I, ttl: Option<i64>) -> Result<(), Error>
where I: Iterator<Item=&'a T>
{
let kbuf = serialize(&key, Infinite)?;
let mut vbuf : Vec<u8> = Vec::with_capacity(32);
set_ttl(&mut vbuf, ttl)?;
{
let val : VecDeque<&T> = 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,
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment