#literals

macro alloy-u256-literal

Procedural macro for converting u256 literals to U256 at compile time

1 unstable release

0.1.0 Aug 27, 2024

#138 in #literals

MIT/Apache

5KB
61 lines

This crate provides u256! macro for converting u256 literals to actual alloy_primitives::U256 at compile time. This is helpful when you're trying to define a const U256.

It supports 0x prefix and normal decimals. When the number is too large to fit into U256, it would complain.

This crate assumes you have alloy-primitives added to your Cargo.toml dependency.

Examples

let x = u256!(123454444444444444444444444444444444444444444);
let y = u256!(0x123456789827823721235568483);
let z = u256!(1e18);
let w = u256!(1.23e18);

Dependencies

~5MB
~96K SLoC