diff --git a/src/tinyvec.rs b/src/tinyvec.rs index 1dbfa48..90c197d 100644 --- a/src/tinyvec.rs +++ b/src/tinyvec.rs @@ -709,6 +709,12 @@ impl From> for TinyVec { } } +impl From for TinyVec { + fn from(array: A) -> Self { + TinyVec::Inline(ArrayVec::from(array)) + } +} + impl From<&'_ [T]> for TinyVec where T: Clone + Default, diff --git a/tests/tinyvec.rs b/tests/tinyvec.rs index 617193a..e02b647 100644 --- a/tests/tinyvec.rs +++ b/tests/tinyvec.rs @@ -84,3 +84,10 @@ fn TinyVec_from_slice_impl() { TinyVec::Inline(ArrayVec::from_array_len(same_size, 4)); assert_eq!(TinyVec::from(&same_size[..]), tinyvec); } + +#[test] +fn TinyVec_from_array() { + let array = [9, 8, 7, 6, 5, 4, 3, 2, 1]; + let tv = TinyVec::from(array); + assert_eq!(&array, &tv[..]); +}