mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-15 05:33:07 +00:00
17 lines
250 B
Rust
17 lines
250 B
Rust
use num::Num;
|
|
|
|
/// Integer division that rounds up.
|
|
#[allow(dead_code)]
|
|
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
|
|
}
|
|
}
|