use std::fmt; use crate::table::TableData; #[derive(Clone, Debug)] pub struct Tags { tags: Vec, } impl Default for Tags { fn default() -> Self { Self { tags: vec![] } } } impl TableData for Tags { fn parse(tag_str: &str) -> Result { let tags = tag_str .split(',') .filter_map(|s| match s.is_empty() { true => None, false => Some(s.to_owned()), }) .collect(); Ok(Self { tags }) } } impl fmt::Display for Tags { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let tag_str = self.tags.join(","); write!(f, "{tag_str}") } }