diff --git a/zebra-chain/src/serialization/constraint.rs b/zebra-chain/src/serialization/constraint.rs index ecbfb8da..1aac711c 100644 --- a/zebra-chain/src/serialization/constraint.rs +++ b/zebra-chain/src/serialization/constraint.rs @@ -91,6 +91,23 @@ impl TryFrom> for AtLeastOne { } } +impl TryFrom<&Vec> for AtLeastOne +where + T: Clone, +{ + type Error = SerializationError; + + fn try_from(vec: &Vec) -> Result { + if vec.is_empty() { + Err(SerializationError::Parse("expected at least one item")) + } else { + Ok(AtLeastOne { + inner: vec.to_vec(), + }) + } + } +} + impl TryFrom<&[T]> for AtLeastOne where T: Clone,