Implicitly convert &str to [u8] for compatibility with existing usage code

Thanks to stephaneyfx from the #rust IRC channel for showing me that
this needs separate type parameters on the functions in order to
compile.

The only API change that can't be helped are the `line_junk` and
`char_junk` function pointers in the Differ struct, which now take
`&&str` and `&char` parameters, respectively. This is probably for the
better, since `char_junk` now operates on Unicode scalar values rather
than the single UTF-8 bytes disguised as `&str` that were previously
retrieved via the unsafe `slice_unchecked()` function.
This commit is contained in:
nmlgc
2018-07-05 21:46:43 +02:00
parent 6fd59b0c08
commit 06afc1879b
5 changed files with 33 additions and 19 deletions
+2 -2
View File
@@ -47,7 +47,7 @@ fn main() {
}
//SequenceMatcher examples
let mut matcher = SequenceMatcher::new(b"one two three four", b"zero one tree four");
let mut matcher = SequenceMatcher::new("one two three four", "zero one tree four");
let m = matcher.find_longest_match(0, 18, 0, 18);
println!("{:?}", m);
let all_matches = matcher.get_matching_blocks();
@@ -58,6 +58,6 @@ fn main() {
println!("{:?}", grouped_opcodes);
let ratio = matcher.ratio();
println!("{:?}", ratio);
matcher.set_seqs(b"aaaaa", b"aaaab");
matcher.set_seqs("aaaaa", "aaaab");
println!("{:?}", matcher.ratio());
}