From ef79b98aab6aa9ee3370b41f85899cd608be5dba Mon Sep 17 00:00:00 2001 From: David Blajda Date: Thu, 27 Dec 2018 23:25:08 +0000 Subject: Implement Into for IntId --- Cargo.toml | 2 +- src/types.rs | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9a7902a..5be5744 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "twitch_api" -version = "0.0.31" +version = "0.0.32" authors = ["David Blajda "] 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 { } impl IntegerId { - fn new(id: u32) -> IntegerId { + pub fn new(id: u32) -> IntegerId { IntegerId { inner: Arc::new(IntegerIdRef { id: id.to_string(), @@ -54,6 +54,20 @@ impl AsRef for IntegerId { } } +use std::convert::Into; + +impl Into for &IntegerId { + fn into(self) -> u32 { + self.inner.int + } +} + +impl<'a, T> Into<&'a str> for &'a IntegerId { + fn into(self) -> &'a str { + &self.inner.id + } +} + use std::fmt; use std::fmt::{Display, Debug, Formatter}; -- cgit v1.2.3