I just wrote this function to find differences between two byte lists. Would appreciate any comments on the code in detail, is it correct for example, can it be improved, also on whether there is a better way ( perhaps avoiding a closure parameter, maybe write it as an iterator instead??? ). I haven't defined a function that takes a closure parameter before, so I am still a bit unfamiliar with this.

```
/// Function to compare bytes. Length is taken from a. Calls d for each range that is different.
/// Interior equal ranges less than min_eq are ignored.
pub fn diff<F>(a: &[u8], b: &[u8], min_eq: usize, mut d: F)
where
F: FnMut(usize, usize),
{
let mut i = 0;
let n = a.len();
while i < n && a[i] == b[i] {
i += 1;
}
while i < n {
let start = i;
let mut end;
loop {
while i < n && a[i] != b[i] {
i += 1;
}
end = i;
// Check that following equal range is at least min_eq.
while i < n && a[i] == b[i] {
i += 1;
}
if i - end >= min_eq || i == n {
break;
}
}
if end > start {
d(start, end - start);
}
}
}
```

( Published here: diff in rustdb::util - Rust )