1
2
3
4
5
6
7
8
9
10
11
12
13
use conv::{ConvUtil, RoundToNearest};

pub fn create_padding(element: char, required: usize, actual: usize) -> String {
    if let Some(count) = required.checked_sub(actual) {
        std::iter::repeat(element).take(count).collect()
    } else {
        String::from("")
    }
}

pub fn to_nearest_i64(number: f64) -> i64 {
    number.approx_as_by::<i64, RoundToNearest>().unwrap_or_default()
}