mirror of
https://gitee.com/openharmony/third_party_rust_tinyvec
synced 2024-11-26 23:30:27 +00:00
Error implementation for TryFromSliceError (#160)
* Fix spelling of 'length' * Add Error implementation to TryFromSliceError
This commit is contained in:
parent
7c85b93627
commit
a53c254b88
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user