rust_cutil/cutil/
optionable.rs

1pub trait Optionable {
2  fn to_option(self) -> Option<String>;
3}
4
5impl Optionable for String {
6  fn to_option(self) -> Option<String> {
7    if self.is_empty() {
8      None
9    } else {
10      Some(self)
11    }
12  }
13}