Struct Differ

Source
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

Source

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}
Source

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}
Source

pub fn restore(delta: &[String], which: usize) -> Vec<String>

Trait Implementations§

Source§

impl Default for Differ

Source§

fn default() -> Differ

Returns the “default value” for a type. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.