Skip to content

Commit

Permalink
templater: use property.map() to apply infallible transformation
Browse files Browse the repository at this point in the history
Also renamed data to line as the type name was changed to AnnotationLine.
  • Loading branch information
yuja committed Feb 15, 2025
1 parent e220fe3 commit 6f51696
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cli/src/commit_templater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2234,23 +2234,23 @@ pub fn builtin_annotation_line_methods<'repo>(
"commit",
|_language, _diagnostics, _build_ctx, self_property, function| {
function.expect_no_arguments()?;
let out_property = self_property.and_then(|data| Ok(data.commit));
let out_property = self_property.map(|line| line.commit);
Ok(L::wrap_commit(out_property))
},
);
map.insert(
"line_number",
|_language, _diagnostics, _build_ctx, self_property, function| {
function.expect_no_arguments()?;
let out_property = self_property.and_then(|data| Ok(data.line_number.try_into()?));
let out_property = self_property.and_then(|line| Ok(line.line_number.try_into()?));
Ok(L::wrap_integer(out_property))
},
);
map.insert(
"first_line_in_hunk",
|_language, _diagnostics, _build_ctx, self_property, function| {
function.expect_no_arguments()?;
let out_property = self_property.and_then(|data| Ok(data.first_line_in_hunk));
let out_property = self_property.map(|line| line.first_line_in_hunk);
Ok(L::wrap_boolean(out_property))
},
);
Expand Down

0 comments on commit 6f51696

Please sign in to comment.