1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
mod checksum;
mod iota_units;
mod seed_random_generator;
mod stopwatch;
mod validators;

/// Provides constants for use throughout the library
pub mod constants;
/// Provides useful conversions between trinary types
pub mod converter;
/// Provides validation for types used throughout the library
pub mod input_validator;
/// Provides an adder that sums to slices of trits
pub mod trit_adder;
/// Provides a converter between ascii and tryte-encoded strings
pub mod trytes_converter;
/// Provides unit conversion for Iota
pub mod unit_converter;

pub use self::checksum::*;
pub use self::iota_units::IotaUnits;
pub use self::seed_random_generator::generate_new_seed;
pub use self::stopwatch::StopWatch;
pub use self::validators::*;

/// Right pads a string to a certain length in place
///
/// * `x` - the string to be padded
/// * `len` - the target length of the string
/// * `pad` - the char to pad with
pub fn right_pad_string(x: &mut String, len: usize, pad: char) {
    while x.len() < len {
        x.push(pad);
    }
}

/// Right pads a vector to a certain length in place
///
/// * `x` - the vec to be padded
/// * `len` - the target length of the string`
/// * `pad` - the element to pad with
pub fn right_pad_vec<T>(x: &mut Vec<T>, len: usize, pad: T)
where
    T: Copy,
{
    while x.len() < len {
        x.push(pad);
    }
}