What is a good way to extract data from a &Result
type?
In my specific case, I have a &Result
type, which I
You are looking for Result::as_ref:
Converts from
Result<T, E>
toResult<&T, &E>
.Produces a new
Result
, containing a reference into the original, leaving the original in place.
The following code solves your problem:
let entry: &DirEntry = result.as_ref().unwrap();
For a mutable version, Result::as_mut is provided.