From 9acd9eac29b21af5fea872e11d1bb0c246d44cd7 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Thu, 20 Jan 2022 09:04:14 +0100 Subject: [PATCH] Take Login ext_uris values as a slice to allow caller to avoid allocation In some cases the caller might be able to use a const slice for this. --- src/login.rs | 6 +++--- tests/basic.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/login.rs b/src/login.rs index 1060a89..9899c37 100644 --- a/src/login.rs +++ b/src/login.rs @@ -27,8 +27,8 @@ pub struct Login<'a> { } impl<'a> Login<'a> { - pub fn new(username: &'a str, password: &'a str, ext_uris: Option>) -> Self { - let ext_uris = ext_uris.map(|uris| uris.into_iter().map(|u| u.into()).collect()); + pub fn new(username: &'a str, password: &'a str, ext_uris: Option<&'_ [&'a str]>) -> Self { + let ext_uris = ext_uris.map(|uris| uris.iter().map(|&u| u.into()).collect()); Self { username: username.into(), @@ -72,7 +72,7 @@ mod tests { #[test] fn command() { - let ext_uris = Some(vec!["http://schema.ispapi.net/epp/xml/keyvalue-1.0"]); + let ext_uris = Some(&["http://schema.ispapi.net/epp/xml/keyvalue-1.0"][..]); let xml = get_xml("request/login.xml").unwrap(); let object = Login::new("username", "password", ext_uris); diff --git a/tests/basic.rs b/tests/basic.rs index 7423203..87c701e 100644 --- a/tests/basic.rs +++ b/tests/basic.rs @@ -92,7 +92,7 @@ async fn client() { &Login::new( "username", "password", - Some(vec!["http://schema.ispapi.net/epp/xml/keyvalue-1.0"]), + Some(&["http://schema.ispapi.net/epp/xml/keyvalue-1.0"]), ), CLTRID, )