fn pack<'a>(data_type: &'a SolidityDataType) -> Vec<u8> {
        let mut res = Vec::new();
        match data_type {
            SolidityDataType::String(s) => {
                res.extend(s.as_bytes());
            }
            SolidityDataType::Address(a) => {
                res.extend(a.0);
            }
            SolidityDataType::Number(n) => {
                for b in n.0.iter().rev() {
                    let bytes = b.to_be_bytes();
                    res.extend(bytes);
                }
            }
            SolidityDataType::Bytes(b) => {
                res.extend(*b);
            }
            SolidityDataType::Bool(b) => {
                if *b {
                    res.push(1);
                } else {
                    res.push(0);
                }
            }
            SolidityDataType::NumberWithShift(n, to_take) => {
                let local_res = n.0.iter().rev().fold(vec![], |mut acc, i| {
                    let bytes = i.to_be_bytes();
                    acc.extend(bytes);
                    acc
                });

                let to_skip = local_res.len() - (to_take.0 / 8);
                let local_res = local_res.into_iter().skip(to_skip).collect::<Vec<u8>>();
                res.extend(local_res);
            }
        };
        return res;
    }
/// Pack a single `SolidityDataType` into bytes
Pack a single `SolidityDataType` into bytes
Pack a single ` SolidityDataType ` into bytes
fn pack<'a>(data_type: &'a SolidityDataType) -> Vec<u8> {
        let mut res = Vec::new();
        match data_type {
            SolidityDataType::String(s) => {
                res.extend(s.as_bytes());
            }
            SolidityDataType::Address(a) => {
                res.extend(a.0);
            }
            SolidityDataType::Number(n) => {
                for b in n.0.iter().rev() {
                    let bytes = b.to_be_bytes();
                    res.extend(bytes);
                }
            }
            SolidityDataType::Bytes(b) => {
                res.extend(*b);
            }
            SolidityDataType::Bool(b) => {
                if *b {
                    res.push(1);
                } else {
                    res.push(0);
                }
            }
            SolidityDataType::NumberWithShift(n, to_take) => {
                let local_res = n.0.iter().rev().fold(vec![], |mut acc, i| {
                    let bytes = i.to_be_bytes();
                    acc.extend(bytes);
                    acc
                });
                let to_skip = local_res.len() - (to_take.0 / 8);
                let local_res = local_res.into_iter().skip(to_skip).collect::<Vec<u8>>();
                res.extend(local_res);
            }
        };
        return res;
    }
fn pack < ' a > ( data_type : & ' a SolidityDataType ) -> Vec < u8 > { let mut res = Vec :: new ( ) ; match data_type { SolidityDataType :: String ( s ) => { res . extend ( s . as_bytes ( ) ) ; } SolidityDataType :: Address ( a ) => { res . extend ( a . 0 ) ; } SolidityDataType :: Number ( n ) => { for b in n . 0 . iter ( ) . rev ( ) { let bytes = b . to_be_bytes ( ) ; res . extend ( bytes ) ; } } SolidityDataType :: Bytes ( b ) => { res . extend ( * b ) ; } SolidityDataType :: Bool ( b ) => { if * b { res . push ( 1 ) ; } else { res . push ( 0 ) ; } } SolidityDataType :: NumberWithShift ( n , to_take ) => { let local_res = n . 0 . iter ( ) . rev ( ) . fold ( vec ! [ ] , | mut acc , i | { let bytes = i . to_be_bytes ( ) ; acc . extend ( bytes ) ; acc } ) ; let to_skip = local_res . len ( ) - ( to_take . 0 / 8 ) ; let local_res = local_res . into_iter ( ) . skip ( to_skip ) . collect :: < Vec < u8 > > ( ) ; res . extend ( local_res ) ; } } ; return res ; }
Pack a single `SolidityDataType` into bytes
Pack a single ` SolidityDataType ` into bytes
data_type
&'a SolidityDataType