mirror of
https://github.com/openai/codex.git
synced 2026-04-24 06:35:50 +00:00
avoid matching on as_slice() when you can use is_empty()
This commit is contained in:
@@ -139,11 +139,10 @@ fn parse_string_example(raw: &str) -> Result<Vec<String>> {
|
||||
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<Vec<String>> {
|
||||
})
|
||||
.collect::<Result<_>>()?;
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user