Type hints, also called type annotations, are source-code syntax that explicitly specifies the type of an expression, variable, or parameter. Rust uses them to give the compiler information it may need. section 1.5 section 2.5
Rust uses annotations in several practical situations:
- Annotate a collection while allowing Rust to infer its element type: `let fields: Vec<_> = ...`; `Vec` denotes a dynamically growing vector and `_` requests inference. section 1.5
- Declare function parameter types and the return type: `fn add(i: i32, j: i32) -> i32 { i + j }`. section 2.5
- Disambiguate parsed values when an expression needs a particular type, as in `parse::<f32>()`, which parses a field as a 32-bit floating-point value. section 1.5
- Use annotations selectively: they are relatively rare in ordinary code but are occasionally required as hints to the compiler. section 1.5
Annotating CSV fields
A CSV-processing program splits each record, trims its fields, and collects them into `Vec<_>`. The annotation identifies the collection while leaving the element type for inference. Later, `fields[1].parse::<f32>()` supplies the numeric type needed for a penguin-length value. Debug output shows the parsed records during a debug run, while release output omits that diagnostic output. section 1.5
















