pub struct SequenceMatcher<'a, T: 'a + Sequence> { /* private fields */ }
Implementations§
Source§impl<'a, T: Sequence> SequenceMatcher<'a, T>
impl<'a, T: Sequence> SequenceMatcher<'a, T>
Sourcepub fn new<S>(
first_sequence: &'a S,
second_sequence: &'a S,
) -> SequenceMatcher<'a, T>
pub fn new<S>( first_sequence: &'a S, second_sequence: &'a S, ) -> SequenceMatcher<'a, T>
Examples found in repository?
examples/example.rs (line 50)
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 set_is_junk(&mut self, is_junk: Option<fn(&T) -> bool>)
Sourcepub fn set_seqs<S>(&mut self, first_sequence: &'a S, second_sequence: &'a S)
pub fn set_seqs<S>(&mut self, first_sequence: &'a S, second_sequence: &'a S)
Examples found in repository?
examples/example.rs (line 61)
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 set_first_seq<S>(&mut self, sequence: &'a S)
pub fn set_second_seq<S>(&mut self, sequence: &'a S)
Sourcepub fn find_longest_match(
&self,
first_start: usize,
first_end: usize,
second_start: usize,
second_end: usize,
) -> Match
pub fn find_longest_match( &self, first_start: usize, first_end: usize, second_start: usize, second_end: usize, ) -> Match
Examples found in repository?
examples/example.rs (line 51)
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 get_matching_blocks(&mut self) -> Vec<Match>
pub fn get_matching_blocks(&mut self) -> Vec<Match>
Examples found in repository?
examples/example.rs (line 53)
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 get_opcodes(&mut self) -> Vec<Opcode>
pub fn get_opcodes(&mut self) -> Vec<Opcode>
Examples found in repository?
examples/example.rs (line 55)
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 get_grouped_opcodes(&mut self, n: usize) -> Vec<Vec<Opcode>>
pub fn get_grouped_opcodes(&mut self, n: usize) -> Vec<Vec<Opcode>>
Examples found in repository?
examples/example.rs (line 57)
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 ratio(&mut self) -> f32
pub fn ratio(&mut self) -> f32
Examples found in repository?
examples/example.rs (line 59)
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}
Auto Trait Implementations§
impl<'a, T> Freeze for SequenceMatcher<'a, T>
impl<'a, T> RefUnwindSafe for SequenceMatcher<'a, T>where
T: RefUnwindSafe,
impl<'a, T> Send for SequenceMatcher<'a, T>where
T: Sync,
impl<'a, T> Sync for SequenceMatcher<'a, T>where
T: Sync,
impl<'a, T> Unpin for SequenceMatcher<'a, T>
impl<'a, T> UnwindSafe for SequenceMatcher<'a, T>where
T: RefUnwindSafe,
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