aboutsummaryrefslogtreecommitdiff
path: root/src/util/crdt/deletable.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/crdt/deletable.rs')
-rw-r--r--src/util/crdt/deletable.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/util/crdt/deletable.rs b/src/util/crdt/deletable.rs
index e771aceb..0594d850 100644
--- a/src/util/crdt/deletable.rs
+++ b/src/util/crdt/deletable.rs
@@ -9,6 +9,16 @@ pub enum Deletable<T> {
Deleted,
}
+impl<T> Deletable<T> {
+ /// Map value, used for migrations
+ pub fn map<U, F: FnOnce(T) -> U>(self, f: F) -> Deletable<U> {
+ match self {
+ Self::Present(x) => Deletable::<U>::Present(f(x)),
+ Self::Deleted => Deletable::<U>::Deleted,
+ }
+ }
+}
+
impl<T: Crdt> Deletable<T> {
/// Create a new deletable object that isn't deleted
pub fn present(v: T) -> Self {