pub struct Differ {
pub line_junk: Option<fn(&&str) -> bool>,
pub char_junk: Option<fn(&char) -> bool>,
}
Fields§
§line_junk: Option<fn(&&str) -> bool>
§char_junk: Option<fn(&char) -> bool>
Implementations§
Source§impl Differ
impl Differ
Sourcepub fn new() -> Differ
pub fn new() -> Differ
Examples found in repository?
examples/example.rs (line 43)
6fn main() {
7 // unified_diff
8 let first_text = "one two three four".split(" ").collect::<Vec<&str>>();
9 let second_text = "zero one tree four".split(" ").collect::<Vec<&str>>();
10 let diff = difflib::unified_diff(
11 &first_text,
12 &second_text,
13 "Original",
14 "Current",
15 "2005-01-26 23:30:50",
16 "2010-04-02 10:20:52",
17 3,
18 );
19 for line in &diff {
20 println!("{:?}", line);
21 }
22
23 //context_diff
24 let diff = difflib::context_diff(
25 &first_text,
26 &second_text,
27 "Original",
28 "Current",
29 "2005-01-26 23:30:50",
30 "2010-04-02 10:20:52",
31 3,
32 );
33 for line in &diff {
34 println!("{:?}", line);
35 }
36
37 //get_close_matches
38 let words = vec!["ape", "apple", "peach", "puppy"];
39 let result = difflib::get_close_matches("appel", words, 3, 0.6);
40 println!("{:?}", result);
41
42 //Differ examples
43 let differ = Differ::new();
44 let diff = differ.compare(&first_text, &second_text);
45 for line in &diff {
46 println!("{:?}", line);
47 }
48
49 //SequenceMatcher examples
50 let mut matcher = SequenceMatcher::new("one two three four", "zero one tree four");
51 let m = matcher.find_longest_match(0, 18, 0, 18);
52 println!("{:?}", m);
53 let all_matches = matcher.get_matching_blocks();
54 println!("{:?}", all_matches);
55 let opcode = matcher.get_opcodes();
56 println!("{:?}", opcode);
57 let grouped_opcodes = matcher.get_grouped_opcodes(2);
58 println!("{:?}", grouped_opcodes);
59 let ratio = matcher.ratio();
60 println!("{:?}", ratio);
61 matcher.set_seqs("aaaaa", "aaaab");
62 println!("{:?}", matcher.ratio());
63}
Sourcepub fn compare(
&self,
first_sequence: &[&str],
second_sequence: &[&str],
) -> Vec<String>
pub fn compare( &self, first_sequence: &[&str], second_sequence: &[&str], ) -> Vec<String>
Examples found in repository?
examples/example.rs (line 44)
6fn main() {
7 // unified_diff
8 let first_text = "one two three four".split(" ").collect::<Vec<&str>>();
9 let second_text = "zero one tree four".split(" ").collect::<Vec<&str>>();
10 let diff = difflib::unified_diff(
11 &first_text,
12 &second_text,
13 "Original",
14 "Current",
15 "2005-01-26 23:30:50",
16 "2010-04-02 10:20:52",
17 3,
18 );
19 for line in &diff {
20 println!("{:?}", line);
21 }
22
23 //context_diff
24 let diff = difflib::context_diff(
25 &first_text,
26 &second_text,
27 "Original",
28 "Current",
29 "2005-01-26 23:30:50",
30 "2010-04-02 10:20:52",
31 3,
32 );
33 for line in &diff {
34 println!("{:?}", line);
35 }
36
37 //get_close_matches
38 let words = vec!["ape", "apple", "peach", "puppy"];
39 let result = difflib::get_close_matches("appel", words, 3, 0.6);
40 println!("{:?}", result);
41
42 //Differ examples
43 let differ = Differ::new();
44 let diff = differ.compare(&first_text, &second_text);
45 for line in &diff {
46 println!("{:?}", line);
47 }
48
49 //SequenceMatcher examples
50 let mut matcher = SequenceMatcher::new("one two three four", "zero one tree four");
51 let m = matcher.find_longest_match(0, 18, 0, 18);
52 println!("{:?}", m);
53 let all_matches = matcher.get_matching_blocks();
54 println!("{:?}", all_matches);
55 let opcode = matcher.get_opcodes();
56 println!("{:?}", opcode);
57 let grouped_opcodes = matcher.get_grouped_opcodes(2);
58 println!("{:?}", grouped_opcodes);
59 let ratio = matcher.ratio();
60 println!("{:?}", ratio);
61 matcher.set_seqs("aaaaa", "aaaab");
62 println!("{:?}", matcher.ratio());
63}
pub fn restore(delta: &[String], which: usize) -> Vec<String>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Differ
impl RefUnwindSafe for Differ
impl Send for Differ
impl Sync for Differ
impl Unpin for Differ
impl UnwindSafe for Differ
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more