diff --git a/codex-rs/execpolicy2/src/parser.rs b/codex-rs/execpolicy2/src/parser.rs index b82109f77b..101f86fc4d 100644 --- a/codex-rs/execpolicy2/src/parser.rs +++ b/codex-rs/execpolicy2/src/parser.rs @@ -139,11 +139,10 @@ fn parse_string_example(raw: &str) -> Result> { Error::InvalidExample("example string has invalid shell syntax".to_string()) })?; - match tokens.as_slice() { - [] => Err(Error::InvalidExample( - "example cannot be an empty string".to_string(), - )), - _ => Ok(tokens), + if tokens.is_empty() { + Err(Error::InvalidExample("example cannot be an empty string".to_string())) + } else { + Ok(tokens) } } @@ -164,11 +163,10 @@ fn parse_list_example(list: &ListRef) -> Result> { }) .collect::>()?; - match tokens.as_slice() { - [] => Err(Error::InvalidExample( - "example cannot be an empty list".to_string(), - )), - _ => Ok(tokens), + if tokens.is_empty() { + Err(Error::InvalidExample("example cannot be an empty list".to_string())) + } else { + Ok(tokens) } }