1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crate::{BigUInt, property::IsBigInt, digit::Digit};

impl<T: Copy + Default + Digit, const LEN: usize> BigUInt<T, LEN> {
    /// resize a biguint, expand and set high bits to 0 if new length is larger, 
    /// shrink and cut off higher bits if new length is smaller
    pub fn resize<const L: usize>(self) -> BigUInt<T, L> {
        let mut output = BigUInt::ZERO;

        if L >= LEN {
            output[..LEN].copy_from_slice(&self.0)
        } else {
            output.copy_from_slice(&self.0[..L])
        }

        output
    }
}