From 556510f378bc11bebefff31729cec62dedbe01fe Mon Sep 17 00:00:00 2001 From: kevin zhao Date: Wed, 12 Nov 2025 20:00:12 -0500 Subject: [PATCH] avoid matching on as_slice() when you can use is_empty() --- codex-rs/execpolicy2/src/parser.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) 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) } }