Add in some missing types, conversions and utility methods.
This commit is contained in:
parent
ece0b39a60
commit
e2f6fd0c08
|
@ -69,6 +69,12 @@ impl From<Id> for Class {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a str> for Class {
|
||||
fn from(str: &'a str) -> Self {
|
||||
Class::from_str(str).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for Class {
|
||||
fn fmt(&self, f: &mut Formatter) -> Result<(), Error> {
|
||||
Display::fmt(&self.0, f)
|
||||
|
|
|
@ -58,6 +58,12 @@ impl FromStr for Id {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a str> for Id {
|
||||
fn from(str: &'a str) -> Self {
|
||||
Id::from_str(str).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Class> for Id {
|
||||
fn from(c: Class) -> Self {
|
||||
Id(c.to_string())
|
||||
|
|
|
@ -104,6 +104,16 @@ pub enum FormMethod {
|
|||
Get,
|
||||
}
|
||||
|
||||
#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, AsStaticStr)]
|
||||
pub enum FormDialogMethod {
|
||||
#[strum(to_string = "post")]
|
||||
Post,
|
||||
#[strum(to_string = "get")]
|
||||
Get,
|
||||
#[strum(to_string = "dialog")]
|
||||
Dialog,
|
||||
}
|
||||
|
||||
#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, AsStaticStr)]
|
||||
pub enum HTTPEquiv {
|
||||
#[strum(to_string = "content-security-policy")]
|
||||
|
|
|
@ -33,6 +33,11 @@ impl<A: Ord> SpacedSet<A> {
|
|||
pub fn new() -> Self {
|
||||
SpacedSet(BTreeSet::new())
|
||||
}
|
||||
|
||||
/// Add a value to the `SpacedSet`.
|
||||
pub fn add<T: Into<A>>(&mut self, value: T) -> bool {
|
||||
self.0.insert(value.into())
|
||||
}
|
||||
}
|
||||
|
||||
impl<A: Ord> Default for SpacedSet<A> {
|
||||
|
|
Loading…
Reference in New Issue