diff --git a/src/patch/mod.rs b/src/patch/mod.rs index eaaff2f1..cff18b62 100644 --- a/src/patch/mod.rs +++ b/src/patch/mod.rs @@ -639,6 +639,7 @@ fn check_offsets(offsets: &[u32], dim_increment: u32) -> bool { true } +/// Compare 2 strings and return index of first different char fn first_diff(s1: &str, s2: &str) -> usize { for ((i, c1), c2) in s1.char_indices().zip(s2.chars()) { if c1 != c2 { @@ -647,6 +648,7 @@ fn first_diff(s1: &str, s2: &str) -> usize { } s1.len().min(s2.len()) } +/// Replace first occurrence of `pat` in string starting from byte `i` fn replacefirstfrom<'a>(s: &'a str, pat: &str, to: &str, i: usize) -> Cow<'a, str> { if i >= s.len() { s.into() @@ -655,6 +657,8 @@ fn replacefirstfrom<'a>(s: &'a str, pat: &str, to: &str, i: usize) -> Cow<'a, st format!("{s1}{}", &s2.replacen(pat, to, 1)).into() } } +/// Tries to get common description (or displayNames) for register/field array with "%s" in index position. +/// Returns `None` if incoming descriptions have more then 1 difference fn common_description(descs: &[Option<&str>], dim_index: &[String]) -> Option> { let mut start = 0; if descs.len() > 1 {