fizyk20 / generic-array

Generic array types in Rust
MIT License
404 stars 77 forks source link

Add try_from_slice() and try_from_mut_slice() #117

Closed peterkelly closed 1 year ago

peterkelly commented 3 years ago

Add two new methods for creating a GenericArray reference from a slice in situations where the caller doesn't know the length of the incoming slice. In such a situation, these methods are safer than from_slice() and from_mut_slice() because they don't panic.

fjarri commented 1 year ago

I think it would be even more convenient as a TryFrom<&[u8]> impl.