From: chris mikkelson Date: Mon, 29 Jul 2024 18:45:20 +0000 (-0500) Subject: source.rs: Remove unneeded GenSource trait X-Git-Url: https://git.mikk.net/?a=commitdiff_plain;h=422a14711bdfe4592136a89d7cde5d30c8fef09b;p=mtbl-rs source.rs: Remove unneeded GenSource trait Rename GenWrap to BoxWrap for clarity. --- diff --git a/src/source.rs b/src/source.rs index 4e25abc..6699f8e 100644 --- a/src/source.rs +++ b/src/source.rs @@ -119,19 +119,14 @@ impl Iter for RangeIter { } } -trait GenSource<'a>: - Source, Get = BoxedIter<'a>, Prefix = BoxedIter<'a>, Range = BoxedIter<'a>> + 'a -{ -} - -struct GenWrap<'a, S: Source + 'a>(S, PhantomData<&'a S>); -impl<'a, S: Source + 'a> IterSource for GenWrap<'a, S> { +struct BoxWrap<'a, S: Source + 'a>(S, PhantomData<&'a S>); +impl<'a, S: Source + 'a> IterSource for BoxWrap<'a, S> { type It = BoxedIter<'a>; fn iter(&self) -> Self::It { Box::new(self.0.iter()) } } -impl<'a, S: Source + 'a> Source for GenWrap<'a, S> { +impl<'a, S: Source + 'a> Source for BoxWrap<'a, S> { type Get = BoxedIter<'a>; fn get(&self, key: &[u8]) -> Self::Get { Box::new(self.0.get(key)) @@ -145,12 +140,20 @@ impl<'a, S: Source + 'a> Source for GenWrap<'a, S> { Box::new(self.0.get_range(start, end)) } } -impl<'a, S: Source + 'a> GenSource<'a> for GenWrap<'a, S> {} -pub struct BoxedSource<'a>(Box>); +pub struct BoxedSource<'a>( + Box< + dyn Source< + It = BoxedIter<'a>, + Get = BoxedIter<'a>, + Prefix = BoxedIter<'a>, + Range = BoxedIter<'a>, + > + 'a, + >, +); impl<'a> BoxedSource<'a> { fn from(source: S) -> Self { - Self(Box::new(GenWrap(source, PhantomData))) + Self(Box::new(BoxWrap(source, PhantomData))) } } impl<'a> IterSource for BoxedSource<'a> {