AppFlowy/frontend/rust-lib/flowy-document/src/parse.rs
Nathan.fooo 5facb61e23
refactor: crates (#4258)
* chore: rename flowy-folder2 to flowy-folder

* chore: rename flowy-document2 to flowy-document

* chore: fix test

* chore: move lib-infra crate

* chore: remove shared-lib

* chore: fix clippy
2023-12-31 07:29:40 +08:00

24 lines
475 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))
}
}
#[derive(Debug)]
pub struct NotEmptyVec<T>(pub Vec<T>);
impl<T> NotEmptyVec<T> {
pub fn parse(v: Vec<T>) -> Result<Self, String> {
if v.is_empty() {
return Err("Input vector is empty".to_owned());
}
Ok(Self(v))
}
}