use gtmpl::Value;
use std::hash::{Hash, Hasher};
use url::Url;
#[derive(Clone, Debug)]
pub struct Tag {
pub name: String,
pub url: Url,
}
impl Hash for Tag {
fn hash<H: Hasher>(&self, state: &mut H) {
self.name.hash(state)
}
}
impl PartialEq for Tag {
fn eq(&self, other: &Self) -> bool {
self.name == other.name
}
}
impl Eq for Tag {}
impl From<&Tag> for Value {
fn from(t: &Tag) -> Value {
use std::collections::HashMap;
let mut m: HashMap<String, Value> = HashMap::new();
m.insert("tag".to_owned(), (&t.name).into());
m.insert("url".to_owned(), Value::String(t.url.to_string()));
Value::Object(m)
}
}