AppFlowy/frontend/rust-lib/flowy-document2/src/parse.rs
Kilu.He 95f8b2e9a4
chore: create redo/undo bridge (#2760)
* chore: create redo/undo bridge

* chore: update test

* chore: review update

* chore: review update

* chore: react redo/undo

* chore: review update

* chore: add test

* chore: review update

* chore: generate document id

* chore: update undo/redo

* chore: update cargo lock
2023-06-15 10:37:51 +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))
}
}