refactor: rename proxy.as_str to proxy.to_string for clarity

This commit is contained in:
monosans
2025-08-15 12:28:43 +03:00
parent a9e50fda5d
commit e36038b6e3
3 changed files with 9 additions and 4 deletions
+1 -1
View File
@@ -58,7 +58,7 @@ pub async fn check_all<R: reqwest::dns::Resolve + 'static>(
Err(e) if tracing::event_enabled!(tracing::Level::DEBUG) => {
tracing::debug!(
"{} | {}",
proxy.as_str(true),
proxy.to_string(true),
pretty_error(&e)
);
}
+1 -1
View File
@@ -240,6 +240,6 @@ where
{
proxies
.into_iter()
.map(move |proxy| proxy.as_str(include_protocol))
.map(move |proxy| proxy.to_string(include_protocol))
.join("\n")
}
+7 -2
View File
@@ -1,4 +1,5 @@
use std::{
fmt::Write as _,
hash::{Hash, Hasher},
str::FromStr,
sync::Arc,
@@ -131,12 +132,14 @@ impl Proxy {
Ok(())
}
pub fn as_str(&self, include_protocol: bool) -> String {
pub fn to_string(&self, include_protocol: bool) -> String {
let mut s = String::new();
if include_protocol {
s.push_str(self.protocol.as_str());
s.push_str("://");
}
if let (Some(username), Some(password)) =
(&self.username, &self.password)
{
@@ -145,9 +148,11 @@ impl Proxy {
s.push_str(password);
s.push('@');
}
s.push_str(&self.host);
s.push(':');
s.push_str(&self.port.to_string());
write!(s, "{}", self.port).unwrap();
s
}
}