Skip to content

Commit

Permalink
refactor(client): set_proxies accepts an slice of references (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
0x676e67 authored Aug 14, 2024
1 parent 4fcbceb commit a25ada0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/set_proxies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("{}", resp.text().await?);

let proxy = rquest::Proxy::all("socks5h://127.0.0.1:1080")?;
client.set_proxies(vec![proxy]);
client.set_proxies(&[proxy]);

let resp = client.get("https://api.ip.sb/ip").send().await?;
println!("{}", resp.text().await?);
Expand Down
2 changes: 1 addition & 1 deletion src/async_impl/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1515,7 +1515,7 @@ impl Client {
}

/// Set the proxies for this client.
pub fn set_proxies(&mut self, proxies: Vec<Proxy>) {
pub fn set_proxies(&mut self, proxies: &[Proxy]) {
Arc::make_mut(&mut self.inner).hyper.set_proxies(proxies);
self.inner.hyper.reset_pool_idle();
}
Expand Down
4 changes: 2 additions & 2 deletions src/connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ impl Connector {
self.proxies.clone()
}

pub(crate) fn set_proxies(&mut self, proxies: Vec<Proxy>) {
Arc::make_mut(&mut self.proxies).clone_from_slice(&proxies);
pub(crate) fn set_proxies(&mut self, proxies: &[Proxy]) {
Arc::make_mut(&mut self.proxies).clone_from_slice(proxies);
}

pub(crate) fn set_local_address(&mut self, addr: Option<IpAddr>) {
Expand Down

0 comments on commit a25ada0

Please sign in to comment.