Fullstop000/wickdb

Use associated type for Iterator trait

Fullstop000 opened this issue · 0 comments

Current Iterator trait just returns Slice in key() and value()

wickdb/src/iterator.rs

Lines 59 to 65 in 6029534

fn key(&self) -> Slice;
/// Return the value for the current entry. The underlying storage for
/// the returned slice is valid only until the next modification of
/// the iterator.
/// REQUIRES: `valid()`
fn value(&self) -> Slice;

This can limit the usage of Iterators. We might want a non-slice key or value.

Consider using an advanced trait with associated type instead:

pub trait Iterator {
    type Key;
    type Value;

    fn key(&self) -> Self::Key;
    fn value(&self) -> Self::Value;
}

Block #49