Skip to content

Instantly share code, notes, and snippets.

@lucperkins
Created December 25, 2022 19:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucperkins/4410e5c8ecdf87f29ef4c806c9bba671 to your computer and use it in GitHub Desktop.
Save lucperkins/4410e5c8ecdf87f29ef4c806c9bba671 to your computer and use it in GitHub Desktop.
pub fn get_or_none<T>(items: Vec<T>) -> Option<Vec<T>> {
if items.is_empty() {
None
} else {
Some(items)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment