Skip to content

Commit

Permalink
fix: AdmitAll & ReinsertNone no longer requires KV default (#51)
Browse files Browse the repository at this point in the history
Signed-off-by: MrCroxx <[email protected]>
  • Loading branch information
MrCroxx authored Jul 5, 2023
1 parent 1018bca commit 011a401
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion foyer-storage/src/admission.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,15 @@ pub trait AdmissionPolicy: Send + Sync + 'static + Debug {
fn judge(&self, key: &Self::Key, value: &Self::Value) -> bool;
}

#[derive(Debug, Default)]
#[derive(Debug)]
pub struct AdmitAll<K: Key, V: Value>(PhantomData<(K, V)>);

impl<K: Key, V: Value> Default for AdmitAll<K, V> {
fn default() -> Self {
Self(PhantomData)
}
}

impl<K: Key, V: Value> AdmissionPolicy for AdmitAll<K, V> {
type Key = K;

Expand Down
8 changes: 7 additions & 1 deletion foyer-storage/src/reinsertion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,15 @@ pub trait ReinsertionPolicy: Send + Sync + 'static + Clone + Debug {
fn judge(&self, key: &Self::Key, value: &Self::Value) -> bool;
}

#[derive(Debug, Default)]
#[derive(Debug)]
pub struct ReinsertNone<K: Key, V: Value>(PhantomData<(K, V)>);

impl<K: Key, V: Value> Default for ReinsertNone<K, V> {
fn default() -> Self {
Self(PhantomData)
}
}

impl<K: Key, V: Value> Clone for ReinsertNone<K, V> {
fn clone(&self) -> Self {
Self(PhantomData)
Expand Down

0 comments on commit 011a401

Please sign in to comment.