假设我有一个x类型为 的值Option<T>,如何将其转换为Option<&T>?
我尝试使用map:
let result = x.map(|x| &x)
^^ Error
Run Code Online (Sandbox Code Playgroud)
但我得到了错误:
cannot return reference to function parameter `x`
returns a reference to data owned by the current function
Run Code Online (Sandbox Code Playgroud)