From 0a5892c67fb02e09a621ac8796ac84232935f5c3 Mon Sep 17 00:00:00 2001 From: David Blajda Date: Wed, 30 Jan 2019 20:34:54 +0000 Subject: Use ToString for endpoint params --- src/client.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/client.rs') diff --git a/src/client.rs b/src/client.rs index 66f32d6..a8bc0b5 100644 --- a/src/client.rs +++ b/src/client.rs @@ -28,6 +28,7 @@ pub trait PaginationTrait { fn cursor<'a>(&'a self) -> Option<&'a str>; } +pub type ParamList<'a> = BTreeMap<&'a str, &'a dyn ToString>; #[derive(Clone)] pub struct Client { @@ -408,7 +409,7 @@ struct RequestRef { impl RequestRef { pub fn new(url: String, - params: BTreeMap<&str, &str>, + params: BTreeMap<&str, &dyn ToString>, client: Client, method: Method, ratelimit: Option, @@ -416,7 +417,7 @@ impl RequestRef { { let mut owned_params = BTreeMap::new(); for (key, value) in params { - owned_params.insert(key.to_owned(), value.to_owned()); + owned_params.insert(key.to_string(), value.to_string()); } RequestRef { @@ -461,7 +462,7 @@ pub struct IterableApiRequest { impl ApiRequest { pub fn new(url: String, - params: BTreeMap<&str, &str>, + params: BTreeMap<&str, &dyn ToString>, client: Client, method: Method, ratelimit: Option, @@ -480,7 +481,7 @@ impl ApiRequest { impl IterableApiRequest { pub fn new(url: String, - params: BTreeMap<&str, &str>, + params: BTreeMap<&str, &dyn ToString>, client: Client, method: Method, ratelimit: Option -- cgit v1.2.3