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:
+2
-2
@@ -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());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user