Error implementation for TryFromSliceError (#160)

* Fix spelling of 'length'

* Add Error implementation to TryFromSliceError
This commit is contained in:
ajtribick 2022-04-23 20:18:14 +02:00 committed by GitHub
parent 7c85b93627
commit a53c254b88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1271,7 +1271,7 @@ impl<A: Array> From<A> for ArrayVec<A> {
.as_slice()
.len()
.try_into()
.expect("ArrayVec::from> lenght must be in range 0..=u16::MAX");
.expect("ArrayVec::from> length must be in range 0..=u16::MAX");
Self { len, data }
}
}
@ -1281,6 +1281,15 @@ impl<A: Array> From<A> for ArrayVec<A> {
#[derive(Debug, Copy, Clone)]
pub struct TryFromSliceError(());
impl core::fmt::Display for TryFromSliceError {
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
f.write_str("could not convert slice to ArrayVec")
}
}
#[cfg(feature = "std")]
impl std::error::Error for TryFromSliceError {}
impl<T, A> TryFrom<&'_ [T]> for ArrayVec<A>
where
T: Clone + Default,