pub fn update_and_fetch<K, V, F>(
        &self,
        key: K,
        mut f: F,
    ) -> io::Result<Option<InlineArray>>
    where
        K: AsRef<[u8]>,
        F: FnMut(Option<&[u8]>) -> Option<V>,
        V: Into<InlineArray>,
    {
        let key_ref = key.as_ref();
        let mut current = self.get(key_ref)?;

        loop {
            let tmp = current.as_ref().map(AsRef::as_ref);
            let next = f(tmp).map(Into::into);
            match self.compare_and_swap::<_, _, InlineArray>(
                key_ref,
                tmp,
                next.clone(),
            )? {
                Ok(_) => return Ok(next),
                Err(CompareAndSwapError { current: cur, .. }) => {
                    current = cur;
                }
            }
        }
    }
Fetch the value, apply a function to it and return the result.

# Note

This may call the function multiple times if the value has been
changed from other threads in the meantime.

# Examples

```
# fn main() -> Result<(), Box<dyn std::error::Error>> {
use sled::{Config, InlineArray};

let config = Config::tmp().unwrap();
let db: sled::Db<1024> = config.open()?;

fn u64_to_ivec(number: u64) -> InlineArray {
InlineArray::from(number.to_be_bytes().to_vec())
}

let zero = u64_to_ivec(0);
let one = u64_to_ivec(1);
let two = u64_to_ivec(2);
let three = u64_to_ivec(3);

fn increment(old: Option<&[u8]>) -> Option<Vec<u8>> {
let number = match old {
Some(bytes) => {
let array: [u8; 8] = bytes.try_into().unwrap();
let number = u64::from_be_bytes(array);
number + 1
}
None => 0,
};

Some(number.to_be_bytes().to_vec())
}

assert_eq!(db.update_and_fetch("counter", increment).unwrap(), Some(zero));
assert_eq!(db.update_and_fetch("counter", increment).unwrap(), Some(one));
assert_eq!(db.update_and_fetch("counter", increment).unwrap(), Some(two));
assert_eq!(db.update_and_fetch("counter", increment).unwrap(), Some(three));
# Ok(()) }
```
src/tree.rs