Add context diff and tests for it

This commit is contained in:
Dima Kudosh
2016-02-28 19:14:11 +03:00
parent 0fa2c80be0
commit 3781894ffc
3 changed files with 85 additions and 2 deletions
+14 -1
View File
@@ -30,10 +30,23 @@ pub fn format_range_unified(start:usize, end: usize) -> String {
println!("{:?} {}", start, end);
let length = end - start;
if length == 1 {
return format!("{}", beginning)
return beginning.to_string()
}
if length == 0 {
beginning -= 1;
}
format!("{},{}", beginning, length)
}
pub fn format_range_context(start: usize, end: usize) -> String {
let mut beginning = start + 1;
let length = end - start;
if length == 0 {
beginning -= 1
}
if length <= 1 {
return beginning.to_string()
}
format!("{},{}", beginning, beginning + length - 1)
}