Add FuzzyEq trait (#3896)
This commit is contained in:
parent
982e6b33fd
commit
0462d6a395
3 changed files with 21 additions and 0 deletions
core/src/dbs
10
core/src/dbs/fuzzy_eq.rs
Normal file
10
core/src/dbs/fuzzy_eq.rs
Normal file
|
@ -0,0 +1,10 @@
|
|||
/// FuzzyEq trait is used to compare objects while ignoring values that are non-deterministic.
|
||||
/// Non detereministic values include:
|
||||
/// - Timestamps
|
||||
/// - UUIDs
|
||||
#[doc(hidden)]
|
||||
pub trait FuzzyEq<Rhs: ?Sized = Self> {
|
||||
/// Use this when comparing objects that you do not want to compare properties that are
|
||||
/// non-deterministic
|
||||
fn fuzzy_eq(&self, other: &Rhs) -> bool;
|
||||
}
|
|
@ -35,5 +35,7 @@ pub(crate) use self::statement::*;
|
|||
pub(crate) use self::transaction::*;
|
||||
pub(crate) use self::variables::*;
|
||||
|
||||
#[doc(hidden)]
|
||||
pub mod fuzzy_eq;
|
||||
#[cfg(test)]
|
||||
pub(crate) mod test;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#[cfg(test)]
|
||||
use crate::dbs::fuzzy_eq::FuzzyEq;
|
||||
use crate::sql::{Object, Uuid, Value};
|
||||
use revision::revisioned;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
@ -57,3 +59,10 @@ impl Notification {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
impl FuzzyEq for Notification {
|
||||
fn fuzzy_eq(&self, other: &Self) -> bool {
|
||||
self.action == other.action && self.result == other.result
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue