diff --git a/src/lib.rs b/src/lib.rs index d4a8f7c..1fc462b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -92,17 +92,9 @@ struct Component { #[declio(ctx = "Len(outputs_len.0.try_into()?)")] outputs: Vec, custom_data_len: Int, - #[declio(ctx = "Len(len_or_neg1(*custom_data_len)?)")] - custom_data: Vec, -} - -fn len_or_neg1(len: Int) -> Result { - // From the spec: - // > If the component has no custom data, -1 may be written instead of 0 - match len.0 { - -1 => Ok(0), - other => other.try_into(), - } + #[declio(skip_if = "custom_data_len.0 == -1")] + #[declio(ctx = "Len(custom_data_len.0.try_into()?)")] + custom_data: Option>, } #[derive(Debug, Encode, Decode)]