Skip to content

Commit

Permalink
Added value_ref and value_mut
Browse files Browse the repository at this point in the history
Fixes #51
  • Loading branch information
mitsuhiko committed Oct 7, 2023
1 parent de45587 commit e85ddb0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,16 @@ impl<T: Clone> Change<T> {
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.
Expand Down

0 comments on commit e85ddb0

Please sign in to comment.