chore: adjust code
This commit is contained in:
parent
910846f2ce
commit
a32c77c5f1
@ -78,30 +78,15 @@ pub struct PrfOption {
|
|||||||
|
|
||||||
impl PrfOption {
|
impl PrfOption {
|
||||||
pub fn merge(one: Option<Self>, other: Option<Self>) -> Option<Self> {
|
pub fn merge(one: Option<Self>, other: Option<Self>) -> Option<Self> {
|
||||||
if one.is_none() {
|
match (one, other) {
|
||||||
return other;
|
(Some(mut a), Some(b)) => {
|
||||||
|
a.user_agent = a.user_agent.or(b.user_agent);
|
||||||
|
a.with_proxy = a.with_proxy.or(b.with_proxy);
|
||||||
|
a.update_interval = a.update_interval.or(b.update_interval);
|
||||||
|
Some(a)
|
||||||
|
}
|
||||||
|
t @ _ => t.0.or(t.1),
|
||||||
}
|
}
|
||||||
|
|
||||||
if one.is_some() && other.is_some() {
|
|
||||||
let mut one = one.unwrap();
|
|
||||||
let other = other.unwrap();
|
|
||||||
|
|
||||||
if let Some(val) = other.user_agent {
|
|
||||||
one.user_agent = Some(val);
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(val) = other.with_proxy {
|
|
||||||
one.with_proxy = Some(val);
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(val) = other.update_interval {
|
|
||||||
one.update_interval = Some(val);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Some(one);
|
|
||||||
}
|
|
||||||
|
|
||||||
return one;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user