Skip to main content

non_empty

Function non_empty 

Source
pub fn non_empty<T>(items: Vec<T>) -> Option<Vec<T>>
Expand description

The Option sibling of require_non_empty: None for an empty list, Some(items) otherwise.

This is the one home for the “an empty list means absent” rule, wherever a list is being placed into an Option-shaped slot (an optional response content, an optional message) rather than validated. The same whole-list rule applies: never decide emptiness per item.