Skip to content

Commit

Permalink
feat(lib): implement FromStr trait for DnoteBook to parse string into…
Browse files Browse the repository at this point in the history
… struct
  • Loading branch information
deepanchal committed Jul 8, 2023
1 parent 7ca9652 commit 68c4af8
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/dnote_lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
use std::str::FromStr;

#[derive(Debug, Clone)]
pub struct DnoteBook {
pub name: String,
}

impl FromStr for DnoteBook {
type Err = ();
fn from_str(s: &str) -> Result<Self, Self::Err> {
let name = s.trim().to_string();
Ok(DnoteBook { name })
}
}

#[derive(Debug, Clone)]
pub struct DnotePage {
pub id: u32,
Expand Down

0 comments on commit 68c4af8

Please sign in to comment.