cursive/cursive-core/src/div.rs
2020-04-23 13:46:00 -07:00

16 lines
230 B
Rust

use num::Num;
/// Integer division that rounds up.
pub fn div_up<T>(p: T, q: T) -> T
where
T: Num + Clone,
{
let d = p.clone() / q.clone();
if p % q == T::zero() {
d
} else {
T::one() + d
}
}