Type safety uses a strong static type system to know every value’s type at compile time and reject incompatible uses, such as passing a string where a Boolean is required. Rust usually infers local variable types while requiring function input and output types, preserving safety without repetitive annotations. section 1.4.3
Typed data without repetitive declarations
A Java map requires explicit generic and local declarations: `HashMap<Integer, ArrayList<Integer>> map = new HashMap<Integer, ArrayList<Integer>>();`. Rust infers the corresponding types from insertion: `let mut map = HashMap::new(); map.insert(1, vec![4, 10]);`. Explicit types remain available when needed: `HashMap<i32, Vec<i32>>`. section 1.4.3
Listing 1.4 Initializing a map of numbers to lists of numbers in Rust
let mut map = HashMap::new(); map.insert(1, vec![4, 10]);
Shows a compact Rust map whose key and value types are inferred from the inserted data. section 1.4.3







