On more than one occasion I have tried to write something like this
let [n] = slice.try_into()?; // ERROR cannot infer T
but it fails to compile. So I do this.
let [n] = <&[_; 1]>::try_from(slice)?;
but that is no fun. I would like to have
slice::as_array_ref() so I can do this:
let [n] = slice.as_array_ref()?;
Edit: I changed my examples from
if let to
? since that is actually more compelling - if let can just use slice patterns.