Sets intersection
If you have two HashSet<T>
h1
and h2
, you can iterate over their intersection which is denoted by h1.intersection(&h2)
. This will iterate over all common elements using a reference of type &T
.
Exercise 3.a: write a function with signature fn trending() -> Result<Vec<String>, Error>
which returns a vector with the names present in both "https://www.liberation.fr"
and "https://www.mediapart.fr"
. The vector will be sorted before being returned.
Print the trending names from your main()
function:
fn main() -> Result<(), Error> { println!("Trending names:"); for name in trending()? { println!(" - {name}"); } Ok(()) }