Remove one generic bound where unnecessary
@@ -309,8 +309,13 @@ impl Tree {
///
/// assert_eq!(t.update_and_fetch(b"hello", |_old| Some(vec![1])), Ok(Some(IVec::from(vec![1]))));
/// ```
- pub fn update_and_fetch<K, V, F>(&self, key: K, f: F) -> Result<Option<IVec>>
- where K: AsRef<[u8]>,
+ pub fn update_and_fetch<K, V, F>(
+ &self,
+ key: K,
+ f: F,
+ ) -> Result<Option<IVec>>
+ where
+ K: AsRef<[u8]>,
F: Fn(Option<&[u8]>) -> Option<V>,
IVec: From<V>,
{
@@ -343,8 +348,13 @@ impl Tree {
///
/// assert_eq!(t.fetch_and_update(b"hello", |_old| Some(vec![1])), Ok(None));
/// ```
- pub fn fetch_and_update<K, V, F>(&self, key: K, f: F) -> Result<Option<IVec>>
- where K: AsRef<[u8]>,
+ pub fn fetch_and_update<K, V, F>(
+ &self,
+ key: K,
+ f: F,
+ ) -> Result<Option<IVec>>
+ where
+ K: AsRef<[u8]>,
F: Fn(Option<&[u8]>) -> Option<V>,
IVec: From<V>,
{
@@ -353,8 +363,8 @@ impl Tree {
loop {
let tmp = current.as_ref().map(AsRef::as_ref);
- let next = f(tmp).map(IVec::from);
- match self.cas::<_, _, IVec>(key, tmp, next)? {
+ let next = f(tmp);
+ match self.cas(key, tmp, next)? {
Ok(()) => return Ok(current),
Err(new_current) => current = new_current,
}
