I'd like to write a method that looks up a value in the HashMap and returns an iterator over that vector if it's found, and otherwise returns an empty iterator, i.e. something like this:
However, this is not allowed because the two iterators are of different types. Is there an idiomatic way that I can accomplish this? It seems like the sort of thing that should be quite simple, but I can't figure it out.
Edit: to clarify: this works because Vec<T>'s reference iterator comes from &[T]. [] is a constant value, so it can be promoted to a static, which means it's a &'static [T]. That satisfies both the type checker and the borrow checker.