std_ext/option/vec.rs
1pub trait OptionVecExt<T> {
2 fn first(&self) -> Option<&T>;
3 fn is_empty(&self) -> bool;
4}
5
6impl<T> OptionVecExt<T> for Option<Vec<T>> {
7 fn first(&self) -> Option<&T> {
8 self.as_ref().and_then(|v| v.first())
9 }
10 fn is_empty(&self) -> bool {
11 self.as_ref().map_or(true, |v| v.is_empty())
12 }
13}