rust-num / num-rational

Generic Rational numbers for Rust
Apache License 2.0
142 stars 50 forks source link

Divide-by-zero crash occurs on Ratio::trunc() #122

Closed HeeillWang closed 6 months ago

HeeillWang commented 12 months ago

https://github.com/rust-num/num-rational/blob/a3d5ecedfe078b9779b07af5972974a885ef8920/src/lib.rs#L257-L261

Divide-by-zero occurs when self.denom is zero

cuviper commented 12 months ago

What would you expect this to return?

A zero denominator should only be possible with new_raw, which warns about panics already.