From e85ddb0d18f8aef6b1aec2367cadebd03db6e831 Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Sat, 7 Oct 2023 17:17:37 +0200 Subject: [PATCH] Added value_ref and value_mut Fixes #51 --- CHANGELOG.md | 4 ++++ src/types.rs | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 929c668..adcbf42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to similar are documented here. +## 2.3.0 + +* Added support for `Change::value_ref` and `Change::value_mut`. + ## 2.2.1 * Fixed a panic in LCS diffs on matching input. (#43) diff --git a/src/types.rs b/src/types.rs index 8967676..4efbad4 100644 --- a/src/types.rs +++ b/src/types.rs @@ -103,6 +103,16 @@ impl Change { pub fn value(&self) -> T { self.value.clone() } + + /// Returns the underlying changed value as reference. + pub fn value_ref(&self) -> &T { + &self.value + } + + /// Returns the underlying changed value as mutable reference. + pub fn value_mut(&mut self) -> &mut T { + &mut self.value + } } /// Utility enum to capture a diff operation.