Skip to content

Commit

Permalink
refactor: use Option::transpose
Browse files Browse the repository at this point in the history
  • Loading branch information
desbma committed Nov 20, 2024
1 parent 4722239 commit bc55cb1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/strace/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl LogParser {
let file = File::options().create(true).append(true).open(p)?;
Ok(BufWriter::with_capacity(64 * 1024, file))
})
.map_or(Ok(None), |v| v.map(Some))?;
.transpose()?;
Ok(Self {
reader,
log,
Expand Down
4 changes: 2 additions & 2 deletions src/strace/parser/peg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ fn lit_pair(pair: Pair<Rule>) -> anyhow::Result<IntegerExpression> {
val_pair.as_str().parse()?,
metadata_pair
.map(|p| BufferExpression::try_from(p).map(|e| e.value))
.map_or(Ok(None), |v| v.map(Some))?,
.transpose()?,
)
}
_ => anyhow::bail!("Unhandled pair: {pair:?}"),
Expand Down Expand Up @@ -221,7 +221,7 @@ impl TryFrom<Pair<'_, Rule>> for IntegerExpression {
value: IntegerExpressionValue::NamedConst(val_pair.as_str().to_owned()),
metadata: metadata_pair
.map(|p| BufferExpression::try_from(p).map(|e| e.value))
.map_or(Ok(None), |v| v.map(Some))?,
.transpose()?,
})
}
Rule::or => {
Expand Down

0 comments on commit bc55cb1

Please sign in to comment.