m/cup
1
0
mirror of https://github.com/sergi0g/cup.git synced 2025-11-17 09:33:38 -05:00

refactor: use array slices instead of vectors wherever possible

This commit is contained in:
Sergio
2025-03-19 19:20:29 +02:00
parent ccf825df24
commit 77a07013a9
3 changed files with 22 additions and 19 deletions

View File

@@ -42,7 +42,7 @@ impl Client {
&self,
url: &str,
method: RequestMethod,
headers: Vec<(&str, Option<&str>)>,
headers: &[(&str, Option<&str>)],
ignore_401: bool,
) -> Result<Response, String> {
let mut request = match method {
@@ -51,7 +51,7 @@ impl Client {
};
for (name, value) in headers {
if let Some(v) = value {
request = request.header(name, v)
request = request.header(*name, *v)
}
}
match request.send().await {
@@ -114,7 +114,7 @@ impl Client {
pub async fn get(
&self,
url: &str,
headers: Vec<(&str, Option<&str>)>,
headers: &[(&str, Option<&str>)],
ignore_401: bool,
) -> Result<Response, String> {
self.request(url, RequestMethod::GET, headers, ignore_401)
@@ -124,7 +124,7 @@ impl Client {
pub async fn head(
&self,
url: &str,
headers: Vec<(&str, Option<&str>)>,
headers: &[(&str, Option<&str>)],
) -> Result<Response, String> {
self.request(url, RequestMethod::HEAD, headers, false).await
}