为什么不允许引用字符串(&String)、Vec(&Vec)或Box(&Box)作为函数参数?
&String
fn awesome_greeting(name: &String) { println!("Wow, you are awesome, {}!", name);}
Vec
Box
:
fn total_price(prices: &Vec<i32>) -> i32 { prices.iter().sum()}fn is_even(value: &Box<i32>) -> bool { **value % 2 == 0}
皈依舞