Я хочу сгруппировать вектор по ключу, когда ключ является вектором.
struct Document {
categories: Vec<String>,
body: String
}
let docs = vec![Document {categories: ["rust".to_string(), body: "doc1".to_string()]},
Document {categories: ["clojure".to_string()], body: "doc2".to_string()},
Document {categories: ["java".to_string()], body: "doc3".to_string()},
Document {categories: ["rust".to_string(), "clojure".to_string], body: "doc4".to_string()}];
Я хочу вернуться, как показано ниже (category_key, documents)
"rust" => [doc1, doc4]
"clojure" => [doc2, doc4]
"java" => [doc3]