kurtbuilds_std_ext 0.1.13

Standard library extensions
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
pub trait OptionVecExt<T> {
    fn first(&self) -> Option<&T>;
    fn is_empty(&self) -> bool;
}

impl<T> OptionVecExt<T> for Option<Vec<T>> {
    fn first(&self) -> Option<&T> {
        self.as_ref().and_then(|v| v.first())
    }
    fn is_empty(&self) -> bool {
        self.as_ref().map_or(true, |v| v.is_empty())
    }
}