Use &str instead of AsRef<str> to be consistent with the API

This commit is contained in:
bbx0
2020-04-12 13:25:25 +02:00
committed by Martin Algesten
parent 3bedf9ab69
commit 55f42a614b

View File

@@ -197,18 +197,12 @@ impl Request {
/// println!("{:?}", r); /// println!("{:?}", r);
/// } /// }
/// ``` /// ```
pub fn send_form<I, K, V>(&mut self, pairs: I) -> Response pub fn send_form(&mut self, data: &[(&str, &str)]) -> Response {
where
I: IntoIterator,
I::Item: Borrow<(K, V)>,
K: AsRef<str>,
V: AsRef<str>,
{
if self.header("Content-Type").is_none() { if self.header("Content-Type").is_none() {
self.set("Content-Type", "application/x-www-form-urlencoded"); self.set("Content-Type", "application/x-www-form-urlencoded");
} }
let encoded = form_urlencoded::Serializer::new(String::new()) let encoded = form_urlencoded::Serializer::new(String::new())
.extend_pairs(pairs) .extend_pairs(data)
.finish(); .finish();
self.do_call(Payload::Bytes(encoded.into_bytes())) self.do_call(Payload::Bytes(encoded.into_bytes()))
} }