Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: better architecture for differ library #38

Merged
merged 2 commits into from
Jan 13, 2023
Merged

Conversation

notalfredo
Copy link
Member

fixes #36

Copy link
Contributor

@neoncitylights neoncitylights left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Here's the first initial review.

crates/differ/README.md Outdated Show resolved Hide resolved
crates/differ/src/apply_diff.rs Outdated Show resolved Hide resolved
crates/differ/src/diff_score.rs Outdated Show resolved Hide resolved
crates/differ/src/diff.rs Outdated Show resolved Hide resolved
crates/differ/src/diff.rs Outdated Show resolved Hide resolved
crates/differ/src/lib.rs Outdated Show resolved Hide resolved
crates/differ/README.md Outdated Show resolved Hide resolved
crates/differ/README.md Outdated Show resolved Hide resolved
crates/differ/README.md Outdated Show resolved Hide resolved
crates/differ/src/apply_diff.rs Outdated Show resolved Hide resolved
* `apply_diff` works by giving a string and a transformation vector to the method. Then the transformation vector is applied to the string given in the first argument.
* `StringDiffAlgorithm` provides two methods `diff` which gives you a transformation vector from the first to second string. The `distance` method gives you the edit distance from the frist argument to the second argument. The structs `HammingDistance` and `LevenshteinDistance` have their own implementations for each method.
* `apply_diff()` works by giving a string and a transformation vector to the method. Then the transformation vector is applied to the string given in the first argument.
* `Diff` holds a `Box<StringDiffOp>`, and the longest length of any two strings. Both `levenshtein()`, and `hamming()` eturn this struct.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo near end of sentence: return this struct

pub fn new(diffs: Vec<StringDiffOp>, total_len: usize) -> Self {
Self {
ops: diffs.into_boxed_slice(),
total_len: total_len,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can simplify to total_len, no need to declare it twice

@neoncitylights neoncitylights merged commit cf74525 into main Jan 13, 2023
@neoncitylights neoncitylights deleted the refactor branch January 13, 2023 01:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

refactor: better architecture for differ library
2 participants