diff --git a/src/lib.rs b/src/lib.rs
index 07465bb..93de30e 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1056,6 +1056,26 @@ impl Extend for NonEmpty {
}
}
+impl From<[T; S]> for NonEmpty {
+ fn from(array: [T; S]) -> Self {
+ const {
+ if S == 0 {
+ panic!("tried to construct NonEmpty from an empty array")
+ }
+ }
+
+ let mut iter = array.into_iter();
+
+ // SAFETY: we know that S is not 0, so we can safely unwrap
+ let head = iter.next().unwrap();
+
+ NonEmpty {
+ head,
+ tail: iter.collect(),
+ }
+ }
+}
+
#[cfg(feature = "serialize")]
pub mod serialize {
use core::{convert::TryFrom, fmt};