Skip to content

Commit

Permalink
Use if let
Browse files Browse the repository at this point in the history
  • Loading branch information
harupy committed Nov 16, 2022
1 parent 718c660 commit b633339
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,22 @@ impl fmt::Display for Message {
self.kind.code().as_ref().red().bold(),
self.kind.body(),
);
let slices = if self.show_source && self.source.is_some() && self.range.is_some() {
vec![Slice {
source: self.source.as_ref().unwrap(),
line_start: self.location.row(),
origin: None,
fold: false,
annotations: vec![SourceAnnotation {
label: "",
annotation_type: AnnotationType::Error,
range: self.range.unwrap(),
}],
}]
let slices = if self.show_source {
if let (Some(source), Some(range)) = (&self.source, self.range) {
vec![Slice {
source,
line_start: self.location.row(),
origin: None,
fold: false,
annotations: vec![SourceAnnotation {
label: "",
annotation_type: AnnotationType::Error,
range,
}],
}]
} else {
vec![]
}
} else {
vec![]
};
Expand Down

0 comments on commit b633339

Please sign in to comment.