From a604fed636e762a7f756cf74233ef6628e30390b Mon Sep 17 00:00:00 2001 From: Izzy McCabe Date: Tue, 7 Jul 2026 13:09:17 -0700 Subject: [PATCH 1/2] is_set_and + is_unchanged_and --- src/entity/active_value.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/entity/active_value.rs b/src/entity/active_value.rs index f435e6597..1081370b3 100644 --- a/src/entity/active_value.rs +++ b/src/entity/active_value.rs @@ -240,6 +240,12 @@ where matches!(self, Self::Set(_)) } + /// Check if the [ActiveValue] is [ActiveValue::Set] and that the inner value + /// matches a given predicate. + pub fn is_set_and(&self, f: impl FnOnce(&V) -> bool) -> bool { + matches!(self, Self::Set(v) && f(v)) + } + /// Create an [ActiveValue::Unchanged] pub fn unchanged(value: V) -> Self { Self::Unchanged(value) @@ -250,6 +256,12 @@ where matches!(self, Self::Unchanged(_)) } + /// Check if the [ActiveValue] is [ActiveValue::Unchanged] and that the inner + /// value matches a given predicate. + pub fn is_unchanged_and(&self, f: impl FnOnce(&V) -> bool) -> bool { + matches!(self, Self::Unchanged(v) && f(v)) + } + /// Create an [ActiveValue::NotSet] pub fn not_set() -> Self { Self::default() From 0f8d8ae528782fd512eb2fbb333d5a5c9552af0c Mon Sep 17 00:00:00 2001 From: Izzy McCabe Date: Tue, 7 Jul 2026 13:19:07 -0700 Subject: [PATCH 2/2] fix broken matches --- src/entity/active_value.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/entity/active_value.rs b/src/entity/active_value.rs index 1081370b3..50c9ac436 100644 --- a/src/entity/active_value.rs +++ b/src/entity/active_value.rs @@ -243,7 +243,7 @@ where /// Check if the [ActiveValue] is [ActiveValue::Set] and that the inner value /// matches a given predicate. pub fn is_set_and(&self, f: impl FnOnce(&V) -> bool) -> bool { - matches!(self, Self::Set(v) && f(v)) + matches!(self, Self::Set(v) if f(v)) } /// Create an [ActiveValue::Unchanged] @@ -259,7 +259,7 @@ where /// Check if the [ActiveValue] is [ActiveValue::Unchanged] and that the inner /// value matches a given predicate. pub fn is_unchanged_and(&self, f: impl FnOnce(&V) -> bool) -> bool { - matches!(self, Self::Unchanged(v) && f(v)) + matches!(self, Self::Unchanged(v) if f(v)) } /// Create an [ActiveValue::NotSet]