mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-16 18:02:56 +00:00
Simplify code: fewer lifetimes, auto-impl VecFrozenVersion
This commit is contained in:
@@ -48,11 +48,20 @@ pub trait VecReadableVersion<Modification: RangeModification<Key>, Key> {
|
||||
fn get(&self, keys: Range<Key>) -> Modification::Result;
|
||||
}
|
||||
|
||||
// TODO: use trait alias when stabilized
|
||||
pub trait VecFrozenVersion<Modification: RangeModification<Key>, Key>:
|
||||
Clone + VecReadableVersion<Modification, Key>
|
||||
{
|
||||
}
|
||||
|
||||
impl<
|
||||
T: Clone + VecReadableVersion<Modification, Key>,
|
||||
Modification: RangeModification<Key>,
|
||||
Key,
|
||||
> VecFrozenVersion<Modification, Key> for T
|
||||
{
|
||||
}
|
||||
|
||||
pub trait PersistentVecStorage<
|
||||
Modification: RangeModification<Key>,
|
||||
Initializer: LazyRangeInitializer<Modification::Result, Key>,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::{
|
||||
LazyRangeInitializer, PersistentVecStorage, RangeModification, RangeQueryResult,
|
||||
VecFrozenVersion, VecReadableVersion,
|
||||
VecReadableVersion,
|
||||
};
|
||||
use std::marker::PhantomData;
|
||||
use std::ops::Range;
|
||||
@@ -42,7 +42,7 @@ impl<Modification: RangeModification<Key>, Key: IndexableKey> VecReadableVersion
|
||||
}
|
||||
|
||||
// Manual implementation of `Clone` becase `derive` requires `Modification: Clone`
|
||||
impl<'a, Modification: RangeModification<Key>, Key: Clone> Clone
|
||||
impl<Modification: RangeModification<Key>, Key: Clone> Clone
|
||||
for NaiveFrozenVersion<Modification, Key>
|
||||
{
|
||||
fn clone(&self) -> Self {
|
||||
@@ -53,11 +53,6 @@ impl<'a, Modification: RangeModification<Key>, Key: Clone> Clone
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, Modification: RangeModification<Key>, Key: IndexableKey>
|
||||
VecFrozenVersion<Modification, Key> for NaiveFrozenVersion<Modification, Key>
|
||||
{
|
||||
}
|
||||
|
||||
// TODO: is it at all possible to store previous versions in this struct,
|
||||
// without any Rc<>?
|
||||
pub struct NaiveVecStorage<
|
||||
|
||||
@@ -90,7 +90,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
fn apply<'a>(&self, result: &'a mut SumResult<T>, range: &Range<Key>) {
|
||||
fn apply(&self, result: &mut SumResult<T>, range: &Range<Key>) {
|
||||
use AddAssignModification::*;
|
||||
match self {
|
||||
None => {}
|
||||
|
||||
Reference in New Issue
Block a user