a bit of cleanup

This commit is contained in:
Andrei Stoica 2024-04-09 20:05:58 -04:00
parent d910f78afd
commit 51574e1403
1 changed files with 8 additions and 11 deletions

View File

@ -164,21 +164,18 @@ impl<'a> TryFrom<&'a AstNode<'a>> for TaskGroup {
let node_ref = &node.data.borrow(); let node_ref = &node.data.borrow();
if let NodeValue::Heading(heading) = node_ref.value { if let NodeValue::Heading(heading) = node_ref.value {
let level = heading.level; let level = heading.level;
let first_child_ref = &node.first_child(); let first_child = node
let first_child = if let Some(child) = first_child_ref { .first_child()
child .ok_or(TaskError::ParsingError("Node has no children"))?;
} else {
return Err(TaskError::ParsingError("Node has no children"));
};
let data_ref = &first_child.data.borrow(); let data_ref = first_child.data.borrow();
let name = if let NodeValue::Text(value) = &data_ref.value { let name = if let NodeValue::Text(value) = &data_ref.value {
value.to_string() Ok(value.to_string())
} else { } else {
return Err(TaskError::ParsingError( Err(TaskError::ParsingError(
"Could not get title from heading node", "Could not get title from heading node",
)); ))
}; }?;
let next_sib = node let next_sib = node
.next_sibling() .next_sibling()