Why do I not need to explicitly lend a borrowed, mutable variable?
问题 I've just written a small Rust program which calculates Fibonacci numbers and memoizes the calculation. It works, but I'm a little confused about why, especially the recursive call. (It also probably isn't idiomatic.) Here's the program: use std::collections::HashMap; fn main() { let n = 42; // hardcoded for simplicity let mut cache = HashMap::new(); let answer = fib(n, &mut cache); println!("fib of {} is {}", n, answer); } fn fib(n: i32, cache: &mut HashMap<i32,i32>) -> i32 { if cache