|
|
|
|
|
by aweinstock
3564 days ago
|
|
Rust's set types do implement the BitAnd and BitOr traits, which allow using the & operator for intersection, | for union (There's also a few others, like (Sub, -, set difference) and (BitXor, ^, symmetric difference)). They use Clone to construct a new set for the result, for use with a functional style. There are also the union/intersection methods that produce lazy iterators over references to the values in the sets, for cases where cloning the set elements would be too big a runtime price, at a slight cost to ergonomics. Clone-based operator overloading: https://doc.rust-lang.org/std/collections/struct.HashSet.htm... https://doc.rust-lang.org/std/collections/struct.HashSet.htm... Lazy-iterator-based methods: https://doc.rust-lang.org/std/collections/struct.HashSet.htm... https://doc.rust-lang.org/std/collections/struct.HashSet.htm... Do these qualify as reasonable set operations? |
|