summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Blajda <blajda@hotmail.com>2018-12-27 23:25:08 +0000
committerDavid Blajda <blajda@hotmail.com>2018-12-27 23:25:08 +0000
commitef79b98aab6aa9ee3370b41f85899cd608be5dba (patch)
tree8dd8f0537ebb4bba33ae681d854246382ea0fc0b /src
parente293f486b97b2226fa22c5299ce5065b6fa7a5c1 (diff)
Implement Into for IntId
Diffstat (limited to 'src')
-rw-r--r--src/types.rs16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/types.rs b/src/types.rs
index db8f0cb..f59fd3a 100644
--- a/src/types.rs
+++ b/src/types.rs
@@ -31,7 +31,7 @@ struct IntegerIdRef<T> {
}
impl<T> IntegerId<T> {
- fn new(id: u32) -> IntegerId<T> {
+ pub fn new(id: u32) -> IntegerId<T> {
IntegerId {
inner: Arc::new(IntegerIdRef {
id: id.to_string(),
@@ -54,6 +54,20 @@ impl<T> AsRef<str> for IntegerId<T> {
}
}
+use std::convert::Into;
+
+impl<T> Into<u32> for &IntegerId<T> {
+ fn into(self) -> u32 {
+ self.inner.int
+ }
+}
+
+impl<'a, T> Into<&'a str> for &'a IntegerId<T> {
+ fn into(self) -> &'a str {
+ &self.inner.id
+ }
+}
+
use std::fmt;
use std::fmt::{Display, Debug, Formatter};