Suppose I have a value x
that has the type of Option<T>
, how do I convert it to Option<&T>
?
I tried using map
:
let result = x.map(|x| &x)
^^ Error
But I got the error:
cannot return reference to function parameter `x`
returns a reference to data owned by the current function