Fix use-self
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
c3c91e9d80
commit
eae41fc411
18 changed files with 47 additions and 48 deletions
|
@ -409,7 +409,7 @@ impl Config {
|
|||
.merge(Env::prefixed("CONDUWUIT_").global().split("__"))
|
||||
};
|
||||
|
||||
let config = match raw_config.extract::<Config>() {
|
||||
let config = match raw_config.extract::<Self>() {
|
||||
Err(e) => return Err(Error::BadConfig(format!("{e}"))),
|
||||
Ok(config) => config,
|
||||
};
|
||||
|
|
|
@ -42,11 +42,11 @@ pub enum ProxyConfig {
|
|||
impl ProxyConfig {
|
||||
pub fn to_proxy(&self) -> Result<Option<Proxy>> {
|
||||
Ok(match self.clone() {
|
||||
ProxyConfig::None => None,
|
||||
ProxyConfig::Global {
|
||||
Self::None => None,
|
||||
Self::Global {
|
||||
url,
|
||||
} => Some(Proxy::all(url)?),
|
||||
ProxyConfig::ByDomain(proxies) => Some(Proxy::custom(move |url| {
|
||||
Self::ByDomain(proxies) => Some(Proxy::custom(move |url| {
|
||||
proxies.iter().find_map(|proxy| proxy.for_url(url)).cloned() // first matching
|
||||
// proxy
|
||||
})),
|
||||
|
@ -108,18 +108,18 @@ enum WildCardedDomain {
|
|||
impl WildCardedDomain {
|
||||
fn matches(&self, domain: &str) -> bool {
|
||||
match self {
|
||||
WildCardedDomain::WildCard => true,
|
||||
WildCardedDomain::WildCarded(d) => domain.ends_with(d),
|
||||
WildCardedDomain::Exact(d) => domain == d,
|
||||
Self::WildCard => true,
|
||||
Self::WildCarded(d) => domain.ends_with(d),
|
||||
Self::Exact(d) => domain == d,
|
||||
}
|
||||
}
|
||||
|
||||
fn more_specific_than(&self, other: &Self) -> bool {
|
||||
match (self, other) {
|
||||
(WildCardedDomain::WildCard, WildCardedDomain::WildCard) => false,
|
||||
(_, WildCardedDomain::WildCard) => true,
|
||||
(WildCardedDomain::Exact(a), WildCardedDomain::WildCarded(_)) => other.matches(a),
|
||||
(WildCardedDomain::WildCarded(a), WildCardedDomain::WildCarded(b)) => a != b && a.ends_with(b),
|
||||
(Self::WildCard, Self::WildCard) => false,
|
||||
(_, Self::WildCard) => true,
|
||||
(Self::Exact(a), Self::WildCarded(_)) => other.matches(a),
|
||||
(Self::WildCarded(a), Self::WildCarded(b)) => a != b && a.ends_with(b),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
@ -130,11 +130,11 @@ impl std::str::FromStr for WildCardedDomain {
|
|||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
// maybe do some domain validation?
|
||||
Ok(if s.starts_with("*.") {
|
||||
WildCardedDomain::WildCarded(s[1..].to_owned())
|
||||
Self::WildCarded(s[1..].to_owned())
|
||||
} else if s == "*" {
|
||||
WildCardedDomain::WildCarded(String::new())
|
||||
Self::WildCarded(String::new())
|
||||
} else {
|
||||
WildCardedDomain::Exact(s.to_owned())
|
||||
Self::Exact(s.to_owned())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ pub trait ReloadHandle<L> {
|
|||
}
|
||||
|
||||
impl<L, S> ReloadHandle<L> for reload::Handle<L, S> {
|
||||
fn reload(&self, new_value: L) -> Result<(), reload::Error> { reload::Handle::reload(self, new_value) }
|
||||
fn reload(&self, new_value: L) -> Result<(), reload::Error> { Self::reload(self, new_value) }
|
||||
}
|
||||
|
||||
struct LogLevelReloadHandlesInner {
|
||||
|
@ -37,8 +37,8 @@ pub struct LogLevelReloadHandles {
|
|||
|
||||
impl LogLevelReloadHandles {
|
||||
#[must_use]
|
||||
pub fn new(handles: Vec<Box<dyn ReloadHandle<EnvFilter> + Send + Sync>>) -> LogLevelReloadHandles {
|
||||
LogLevelReloadHandles {
|
||||
pub fn new(handles: Vec<Box<dyn ReloadHandle<EnvFilter> + Send + Sync>>) -> Self {
|
||||
Self {
|
||||
inner: Arc::new(LogLevelReloadHandlesInner {
|
||||
handles,
|
||||
}),
|
||||
|
|
|
@ -29,8 +29,8 @@ impl PduCount {
|
|||
#[must_use]
|
||||
pub fn stringify(&self) -> String {
|
||||
match self {
|
||||
PduCount::Backfilled(x) => format!("-{x}"),
|
||||
PduCount::Normal(x) => x.to_string(),
|
||||
Self::Backfilled(x) => format!("-{x}"),
|
||||
Self::Normal(x) => x.to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -42,10 +42,10 @@ impl PartialOrd for PduCount {
|
|||
impl Ord for PduCount {
|
||||
fn cmp(&self, other: &Self) -> Ordering {
|
||||
match (self, other) {
|
||||
(PduCount::Normal(s), PduCount::Normal(o)) => s.cmp(o),
|
||||
(PduCount::Backfilled(s), PduCount::Backfilled(o)) => o.cmp(s),
|
||||
(PduCount::Normal(_), PduCount::Backfilled(_)) => Ordering::Greater,
|
||||
(PduCount::Backfilled(_), PduCount::Normal(_)) => Ordering::Less,
|
||||
(Self::Normal(s), Self::Normal(o)) => s.cmp(o),
|
||||
(Self::Backfilled(s), Self::Backfilled(o)) => o.cmp(s),
|
||||
(Self::Normal(_), Self::Backfilled(_)) => Ordering::Greater,
|
||||
(Self::Backfilled(_), Self::Normal(_)) => Ordering::Less,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue