diff options
Diffstat (limited to 'src/ids.rs')
-rw-r--r-- | src/ids.rs | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -1,9 +1,9 @@ use std::fmt::Display; +use std::fmt::Error; pub trait Identifier: Display { fn value(&self) -> &str; } - /// Meant to be a helpful trait allowing anything that can be /// identified by the type specified in `ById`. pub trait AsIdentifier<ById: Identifier> { @@ -45,6 +45,14 @@ macro_rules! identifer { self.0.fmt(f) } } + + impl std::str::FromStr for $name { + type Err = Error; + + fn from_str(s: &str) -> Result<Self, Self::Err> { + Ok($name(s.to_string())) + } + } }; } |