#u256 #ethereum #literals #proc-macro

macro alloy-u256-literal

Procedural macro for converting u256 literals to U256 at compile time

1 unstable release

0.1.0 Aug 27, 2024

#26 in #u256

Download history 10/week @ 2025-09-01 31/week @ 2025-09-08 25/week @ 2025-09-15 32/week @ 2025-09-22 78/week @ 2025-09-29 95/week @ 2025-10-06 45/week @ 2025-10-13 63/week @ 2025-10-20 70/week @ 2025-10-27 87/week @ 2025-11-03 117/week @ 2025-11-10 79/week @ 2025-11-17 11/week @ 2025-11-24 14/week @ 2025-12-01 18/week @ 2025-12-08

54 downloads per month

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

~6MB
~120K SLoC