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