Skip to content

Commit

Permalink
Diffs can now be made
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAlternateDoctor committed Mar 7, 2024
1 parent 1afb648 commit 819abfa
Show file tree
Hide file tree
Showing 4 changed files with 326 additions and 18 deletions.
203 changes: 203 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ bytestream = "0.4.1"
clap = { version = "4.5.1", features = ["derive"] }
regex = "1.10.3"
serde = { version = "1.0.197", features = ["derive"] }
sha256 = "1.5.0"
thiserror = "1.0.56"
toml = "0.8.10"
40 changes: 30 additions & 10 deletions src/diff_utils.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,41 @@
use crate::msbt::MSBTString;

pub fn get_added(original: Vec<MSBTString>, edited: Vec<MSBTString>) -> Vec<MSBTString> {
pub fn get_added(original: Vec<MSBTString>, vec_edited: Vec<Vec<MSBTString>>) -> Vec<MSBTString> {
let mut result = Vec::<MSBTString>::new();
for string in edited {
let index = original.iter().position(|s| s.label == string.label);
if index.is_none(){
result.push(string);
for edited in vec_edited{
for string in edited {
let index = original.iter().position(|s| s.label == string.label);
if index.is_none(){
result.push(string);
}
}
}
return result;
}
pub fn get_deleted(original: Vec<MSBTString>, edited: Vec<MSBTString>) -> Vec<MSBTString> {
pub fn get_deleted(original: Vec<MSBTString>, vec_edited: Vec<Vec<MSBTString>>) -> Vec<MSBTString> {
let mut result = Vec::<MSBTString>::new();
for string in original {
let index = edited.iter().position(|s| s.label == string.label);
if index.is_none(){
result.push(string);
for edited in vec_edited{
for string in &original {
let index = edited.iter().position(|s| s.label == string.label);
if index.is_none(){
result.push(string.to_owned());
}
}
}
return result;
}

pub fn get_edited(original: Vec<MSBTString>, vec_edited: Vec<Vec<MSBTString>>) -> Vec<MSBTString> {
let mut result = Vec::<MSBTString>::new();
for edited in vec_edited{
for string in edited {
let index = original.iter().position(|s| s.label == string.label);
if !index.is_none(){
let string_original = original.get(index.unwrap()).unwrap();
if string_original.string != string.string{
result.push(string);
}
}
}
}
return result;
Expand Down
Loading

0 comments on commit 819abfa

Please sign in to comment.