Simplify code for special case of annotation

This commit is contained in:
AnthonyMikh 2019-09-30 23:33:17 +03:00 committed by GitHub
parent 75a7c27a54
commit 7dc953b493
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -622,18 +622,16 @@ impl EmitterWriter {
// 3 | | // 3 | |
// 4 | | } // 4 | | }
// | |_^ test // | |_^ test
if line.annotations.len() == 1 { if let [ann] = &line.annotations[..] {
if let Some(ref ann) = line.annotations.get(0) { if let AnnotationType::MultilineStart(depth) = ann.annotation_type {
if let AnnotationType::MultilineStart(depth) = ann.annotation_type { if source_string.chars().take(ann.start_col).all(|c| c.is_whitespace()) {
if source_string.chars().take(ann.start_col).all(|c| c.is_whitespace()) { let style = if ann.is_primary {
let style = if ann.is_primary { Style::UnderlinePrimary
Style::UnderlinePrimary } else {
} else { Style::UnderlineSecondary
Style::UnderlineSecondary };
}; buffer.putc(line_offset, width_offset + depth - 1, '/', style);
buffer.putc(line_offset, width_offset + depth - 1, '/', style); return vec![(depth, style)];
return vec![(depth, style)];
}
} }
} }
} }