aboutsummaryrefslogtreecommitdiff
path: root/src/ids.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/ids.rs')
-rw-r--r--src/ids.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/ids.rs b/src/ids.rs
index 2ede5e0..beffd06 100644
--- a/src/ids.rs
+++ b/src/ids.rs
@@ -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()))
+ }
+ }
};
}