spacejam / sled

the champagne of beta embedded databases
Apache License 2.0
7.89k stars 377 forks source link

Can `K` in `Tree::Range` be made `?Sized`? #1497

Open Rafferty97 opened 4 months ago

Rafferty97 commented 4 months ago

The signature of this method is currently:

    pub fn range<K, R>(&self, range: R) -> Iter
    where
        K: AsRef<[u8]>,
        R: RangeBounds<K>;

I am wondering if there is any harm in adding ?Sized to the type parameter K, as follows:

    pub fn range<K, R>(&self, range: R) -> Iter
    where
        K: AsRef<[u8]> + ?Sized,
        R: RangeBounds<K>;

I have a type for which I have implemented std::ops::RangeBounds<[u8]>, however I can't use it as a parameter to the range method due to [u8] being an unsized type, even though that shouldn't be an issue as it's only ever used in its borrowed form &[u8].