Improve type signature of RequestBuilder::basic_auth().

Use Into<String> for both arguments to make the API more convenient.
This commit is contained in:
theduke
2017-05-23 23:59:53 +02:00
parent 241e5069b4
commit 60295dd0fc

View File

@@ -203,10 +203,12 @@ impl RequestBuilder {
}
/// Enable HTTP basic authentication.
pub fn basic_auth(self, username: String, password: Option<String>) -> RequestBuilder {
pub fn basic_auth<U, P>(self, username: U, password: Option<P>) -> RequestBuilder
where U: Into<String>, P: Into<String>
{
self.header(::header::Authorization(::header::Basic{
username: username,
password: password,
username: username.into(),
password: password.map(|p| p.into()),
}))
}