Reputation: 812
I have a hashmap of type HashMap<String, &[T]>
.
Calling hashmap.get(&key)
, returns an Option<&&[T]>
. [Double ampersand]
How do I convert that to Option<&[T]>
? [Single ampersand]
Upvotes: 0
Views: 303
Reputation: 27895
All &
references are Copy
, so you can use Option::copied
:
hashmap.get(&key).copied()
Upvotes: 1