Skip to content

Commit a50a595

Browse files
committed
Use the Position type in the docs
1 parent f19c4e7 commit a50a595

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ using a callback provided to the `Diff` method.
1414
import "github.com/buth/diff"
1515

1616
type edit[T comparable] struct {
17-
start, end int
17+
start, end diff.Position
1818
replacement []T
1919
}
2020

2121
func listOfEdits[T comparable](dst, src []T) []edit[T] {
2222
var edits []edit[T]
23-
diff.Diff(dst, src, nil, func(start, end int, replacement []T) {
23+
diff.Diff(dst, src, nil, func(start, end diff.Position, replacement []T) {
2424
edits = append(edits, edit[T]{
2525
start: start,
2626
end: end,
@@ -44,9 +44,9 @@ func applyEdits[T comparable](src []T, edits []edit[T]) []T {
4444

4545
i := 0
4646
for _, edit := range edits {
47-
dst = append(dst, src[i:edit.start]...)
47+
dst = append(dst, src[i:edit.start.Index]...)
4848
dst = append(dst, edit.replacement...)
49-
i = edit.end
49+
i = edit.end.Index
5050
}
5151

5252
return append(dst, src[i:]...)

0 commit comments

Comments
 (0)