Complete the code to declare a variable with inferred type.
let x = [1];The variable x is assigned the integer 42. Rust infers its type as i32.
Complete the code to declare a variable with inferred string slice type.
let greeting = [1];The variable greeting is assigned a string slice "hello". Rust infers its type as &str.
Fix the error in the code by completing the variable assignment with correct inferred type.
let is_active = [1];The variable is_active is assigned the boolean value true. Rust infers its type as bool.
Fill both blanks to create a vector with inferred type and print its length.
let numbers = vec![[1]]; println!("Length: {}", numbers.[2]());
push instead of len to get length.vec![].The vector numbers is created with integers 1, 2, 3. Rust infers the vector type as Vec. The len() method returns the number of elements.
Fill all three blanks to create a hashmap with inferred types and check if a key exists.
use std::collections::HashMap; let mut scores = HashMap::new(); scores.insert([1], [2]); let has_key = scores.[3](&"Blue");
get instead of contains_key to check existence.The hashmap scores stores a key-value pair with key "Blue" and value 10. The method contains_key checks if the key exists.