Make the change type be generic over any T rather &T (#31)
This makes the interface of this crate more flexible as the utility methods such as `iter_changes` now also work if a container does not contain references.
This commit is contained in:
parent
0b8e237280
commit
a3e10af892
7 changed files with 75 additions and 37 deletions
|
|
@ -159,8 +159,8 @@ impl<'s, T: DiffableStr + ?Sized> InlineChange<'s, T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'s, T: DiffableStr + ?Sized> From<Change<'s, T>> for InlineChange<'s, T> {
|
||||
fn from(change: Change<'s, T>) -> InlineChange<'s, T> {
|
||||
impl<'s, T: DiffableStr + ?Sized> From<Change<&'s T>> for InlineChange<'s, T> {
|
||||
fn from(change: Change<&'s T>) -> InlineChange<'s, T> {
|
||||
InlineChange {
|
||||
tag: change.tag(),
|
||||
old_index: change.old_index(),
|
||||
|
|
|
|||
|
|
@ -495,7 +495,7 @@ impl<'old, 'new, 'bufs, T: DiffableStr + ?Sized + 'old + 'new> TextDiff<'old, 'n
|
|||
pub fn iter_changes<'x, 'slf>(
|
||||
&'slf self,
|
||||
op: &DiffOp,
|
||||
) -> ChangesIter<'slf, 'x, [&'x T], [&'x T], T>
|
||||
) -> ChangesIter<'slf, [&'x T], [&'x T], &'x T>
|
||||
where
|
||||
'x: 'slf,
|
||||
'old: 'x,
|
||||
|
|
@ -728,7 +728,7 @@ fn test_get_close_matches() {
|
|||
fn test_lifetimes_on_iter() {
|
||||
use crate::Change;
|
||||
|
||||
fn diff_lines<'x, T>(old: &'x T, new: &'x T) -> Vec<Change<'x, T::Output>>
|
||||
fn diff_lines<'x, T>(old: &'x T, new: &'x T) -> Vec<Change<&'x T::Output>>
|
||||
where
|
||||
T: DiffableStrRef + ?Sized,
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue