Browse Source

items++

db-refactoring
Coin de Gamma 4 months ago
parent
commit
a3b5f0bcea
  1. 10
      src/db.rs

10
src/db.rs

@ -7,7 +7,7 @@ use std::fmt;
// TODO: use this structure in HashSet of items // TODO: use this structure in HashSet of items
#[derive(Debug, PartialEq, Eq, Hash)] #[derive(PartialEq, Eq, Hash)]
pub struct Item { pub struct Item {
pub id: String, pub id: String,
pub content: String pub content: String
@ -21,7 +21,7 @@ impl Item {
} }
impl fmt::Display for Item { impl fmt::Display for Item {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
writeln!(f, "{}", self.id)?; writeln!(f, "{}", self.id)?;
writeln!(f, "---------")?; writeln!(f, "---------")?;
writeln!(f, "{}", self.content) writeln!(f, "{}", self.content)
@ -29,8 +29,10 @@ impl fmt::Display for Item {
} }
pub fn test_items() { pub fn test_items() {
let item1 = Item::from("item1".to_string()); let mut item1 = Item::from("item1".to_string());
let item2 = Item::from("item2".to_string()); item1.content = "some content".to_string();
let mut item2 = Item::from("item1".to_string());
item2.content = "other content".to_string();
let mut hs = HashSet::<Item>::new(); let mut hs = HashSet::<Item>::new();
hs.insert(item1); hs.insert(item1);

Loading…
Cancel
Save