Implement differ struct

This commit is contained in:
Dima Kudosh
2016-02-18 13:05:52 +03:00
parent b595d39f02
commit 02d2d1762d
2 changed files with 47 additions and 16 deletions
+10
View File
@@ -27,3 +27,13 @@ pub fn str_with_similar_chars(c: char, length: usize) -> String {
}
s
}
pub fn count_leading(line: &str, c: char) -> usize {
let (mut i, n) = (0, line.len());
let line: Vec<char> = line.chars().collect();
while (i < n) && line[i] == c {
i += 1;
}
return i
}