diff options
author | David Blajda <blajda@hotmail.com> | 2018-12-27 23:25:08 +0000 |
---|---|---|
committer | David Blajda <blajda@hotmail.com> | 2018-12-27 23:25:08 +0000 |
commit | ef79b98aab6aa9ee3370b41f85899cd608be5dba (patch) | |
tree | 8dd8f0537ebb4bba33ae681d854246382ea0fc0b | |
parent | e293f486b97b2226fa22c5299ce5065b6fa7a5c1 (diff) |
Implement Into for IntId
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | src/types.rs | 16 |
2 files changed, 16 insertions, 2 deletions
@@ -1,6 +1,6 @@ [package] name = "twitch_api" -version = "0.0.31" +version = "0.0.32" authors = ["David Blajda <blajda@hotmail.com>"] edition = "2018" 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}; |