mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
18 lines
318 B
Rust
18 lines
318 B
Rust
|
#[derive(Debug)]
|
||
|
pub struct NotEmptyStr(pub String);
|
||
|
|
||
|
impl NotEmptyStr {
|
||
|
pub fn parse(s: String) -> Result<Self, String> {
|
||
|
if s.trim().is_empty() {
|
||
|
return Err("Input string is empty".to_owned());
|
||
|
}
|
||
|
Ok(Self(s))
|
||
|
}
|
||
|
}
|
||
|
|
||
|
impl AsRef<str> for NotEmptyStr {
|
||
|
fn as_ref(&self) -> &str {
|
||
|
&self.0
|
||
|
}
|
||
|
}
|