liveBook · Manning

Int32

As explained in Learn Rust in a Month of Lunches

An int32 is a signed integer type represented using exactly 32 bits.

In Rust, `i32` is a signed 32-bit integer type. Rust usually infers `i32` for an integer when you do not specify its type; use an annotation or a literal suffix to choose a type explicitly. section 1.4

fn main() {
    let small_number: u8 = 10;
}

An explicit type annotation makes `small_number` an unsigned integer; use `i32` in the annotation to choose that type instead. section 1.4

An i32 return value

The function signature declares an `i32` return type, and its final expression, `8`, supplies the returned value. section 1.6

How Learn Rust in a Month of Lunches covers it

How deep it goes
Explains inference, annotations, and signatures, but does not discuss numeric bounds.
Examples
Shows an explicitly typed integer, an i32-returning function, and an enum variant carrying i32.
What you can do after
Understand when Rust infers i32 and how annotations and function signatures use it.
How it connects
Connects i32 to type inference, integer annotations, function return values, and enum variants.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Rust in a Month of Lunches. The section links point to the parts of the book it draws on.