Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

318 B
Raw Blame
#[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
  }
}