Function evmil::util::to_be_bytes

source ·
pub fn to_be_bytes(val: u128) -> Vec<u8>
Expand description

Convert a 128bit value into the smallest possible byte sequence (in big endian order).

Examples found in repository?
src/compiler.rs (line 437)
436
437
438
439
440
441
442
443
444
445
fn make_push(val: u128) -> std::result::Result<Instruction,Error> {
    let bytes = to_be_bytes(val);
    // Sanity check size of literal
    if bytes.len() > 32 {
        // Too big!!
        Err(Error::LiteralOverflow)
    } else {
        Ok(Instruction::PUSH(bytes))
    }
}