Skip to content

Commit 367a9e1

Browse files
committed
add diff.Strings
1 parent d44dcdb commit 367a9e1

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

diff.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ type Data interface {
1313
Equal(i, j int) bool
1414
}
1515

16+
// Strings returns the differences of two strings.
17+
func Strings(a, b string) []Change {
18+
return Diff(len(a), len(b), &strings{a, b})
19+
}
20+
21+
type strings struct{ a, b string }
22+
23+
func (d *strings) Equal(i, j int) bool { return d.a[i] == d.b[j] }
24+
1625
// Bytes returns the difference of two byte slices
1726
func Bytes(a, b []byte) []Change {
1827
return Diff(len(a), len(b), &bytes{a, b})

0 commit comments

Comments
 (0)