我想用伪代码执行以下操作:
(a, b, c) = (HashSet(...), HashSet(...), HashSet(...))
(a, b, c) = (a - b - c, b - a - c, c - a - b)
在《铁 rust 》中,我try 了这样的东西:
fn get_random_set(...) -> HashSet<String> {
...
}
// Sets of randomly generated "words" that define behavior of the whole program.
let action_plus: HashSet<String> = get_random_set();
let action_minus: HashSet<String> = get_random_set();
let action_new_line: HashSet<String> = get_random_set();
现在,我们要把所有常见的"词"从这HashSet
个词中剔除.
我了解到difference
和union
方法分别返回Difference
和Union
个迭代器.如果我这么做了:
let action_plus = HashSet::from(action_minus.union(&action_new_line).collect::<Vec<String>>());
我收到这封信:
the trait `From<Vec<String>>` is not implemented for `HashSet<_, _>`
如何处理这个问题?