Unnest another conditional

This commit is contained in:
Carol (Nichols || Goulding) 2019-08-05 12:56:07 -04:00
parent aa67245743
commit 40159362c0
No known key found for this signature in database
GPG Key ID: D04B39A6CA243902
1 changed files with 9 additions and 18 deletions

View File

@ -198,24 +198,15 @@ fn parse_include_path(path: &str) -> LinkType<'static> {
let end = parts.next(); let end = parts.next();
let has_end = end.is_some(); let has_end = end.is_some();
let end = end.and_then(|s| s.parse::<usize>().ok()); let end = end.and_then(|s| s.parse::<usize>().ok());
match start {
Some(start) => match end { match (start, end, has_end) {
Some(end) => LinkType::IncludeRange(path, LineRange::from(start..end)), (Some(start), Some(end), _) => LinkType::IncludeRange(path, LineRange::from(start..end)),
None => { (Some(start), None, true) => LinkType::IncludeRange(path, LineRange::from(start..)),
if has_end { (Some(start), None, false) => {
LinkType::IncludeRange(path, LineRange::from(start..)) LinkType::IncludeRange(path, LineRange::from(start..start + 1))
} else { }
LinkType::IncludeRange( (None, Some(end), _) => LinkType::IncludeRange(path, LineRange::from(..end)),
path, (None, None, _) => LinkType::IncludeRange(path, LineRange::from(RangeFull)),
LineRange::from(start..start + 1),
)
}
}
},
None => match end {
Some(end) => LinkType::IncludeRange(path, LineRange::from(..end)),
None => LinkType::IncludeRange(path, LineRange::from(RangeFull)),
},
} }
} }