Skip to main content

format_int_literal

Function format_int_literal 

Source
pub fn format_int_literal(s: &str, suffix: &str) -> String
Expand description

Format an integer string as a Rust literal with underscores every 3 digits from the right. This satisfies clippy::unreadable_literal for large numbers, for example -2_147_483_648i32.

This function handles hex literals (0x...). It parses them to decimal first, so the output is a clean decimal literal, for example "0x7fffffff" → 2_147_483_647i32.