let sets = [
&mut HashSet::<char>::new(),
&mut HashSet::<char>::new(),
&mut HashSet::<char>::new(),
];
为什么上面的内容不能是这样的:
let sets = [
mut HashSet::<char>::new(),
mut HashSet::<char>::new(),
mut HashSet::<char>::new(),
];
我不需要可变引用,只需要可变值。
当我尝试这样做时,会出现语法错误:
let sets = [
mut HashSet::<char>::new(),
mut HashSet::<char>::new(),
mut HashSet::<char>::new(),
];
let mut sets: [HashSet<char>; 3] = Default::default();
是初始化的一种更短、更少重复的方式。 - Ry-