@@ -444,6 +444,17 @@ impl<'a> ChangeRef<'a> {
444444 | ChangeRef :: Rewrite { location, .. } => location,
445445 }
446446 }
447+
448+ /// Return the *previous* location of the resource where possible, i.e. the source of a rename or copy, or the
449+ /// location at which an addition, deletion or modification took place.
450+ pub fn source_location ( & self ) -> & BStr {
451+ match self {
452+ ChangeRef :: Addition { location, .. }
453+ | ChangeRef :: Deletion { location, .. }
454+ | ChangeRef :: Modification { location, .. } => location,
455+ ChangeRef :: Rewrite { source_location, .. } => source_location,
456+ }
457+ }
447458}
448459
449460impl Change {
@@ -477,4 +488,15 @@ impl Change {
477488 | Change :: Rewrite { location, .. } => location. as_bstr ( ) ,
478489 }
479490 }
491+
492+ /// Return the *previous* location of the resource where possible, i.e. the source of a rename or copy, or the
493+ /// location at which an addition, deletion or modification took place.
494+ pub fn source_location ( & self ) -> & BStr {
495+ match self {
496+ Change :: Addition { location, .. }
497+ | Change :: Deletion { location, .. }
498+ | Change :: Modification { location, .. } => location. as_bstr ( ) ,
499+ Change :: Rewrite { source_location, .. } => source_location. as_bstr ( ) ,
500+ }
501+ }
480502}
0 commit comments