yeslogic / fathom

🚧 (Alpha stage software) A declarative data definition language for formally specifying binary data formats. 🚧
Apache License 2.0
258 stars 14 forks source link

Use `Iterator::try_fold` instead of `fold` when renaming terms #464

Closed Kmeakin closed 1 year ago

Kmeakin commented 1 year ago

Encountered this while writing my own unifier (https://github.com/Kmeakin/pion/blob/master/crates/pion-core/src/elab/unify.rs#L415). try_fold is short circuiting (will return early on the first Err), while fold is not.

Kmeakin commented 1 year ago

Submitted an issue to detect this pattern with clippy: https://github.com/rust-lang/rust-clippy/issues/10208

brendanzab commented 1 year ago

Ooh, very handy!