0

Rust – Convert Integer to String

In Rust, we can use the to_string() and format! functions

Integer Types

There are six (6) integer types in Rust.

i8/u8 to String

8-bit value – signed or unsigned.

Output:

i16/u16 to String

16-bit value – signed or unsigned.

Output:

i32/u32 to String

32-bit value – signed or unsigned.

Output:

i64/u64 to String

64-bit value – signed or unsigned.

Output:

i128/u128 to String

128-bit value – signed or unsigned.

Output:

isize/usize to String

N-bit value – signed or unsigned. These types depend on the kind of computer the program is running on: 64 bits for 64-bit architecture and 32 bits for 32-bit architecture machines.

Output:

Tested with Rust 1.37.0.

Karl San Gabriel

Karl San Gabriel

Professional Software Developer