remove clone bound

This commit is contained in:
jdeepee 2020-10-28 10:51:33 +00:00
parent a5ecb5887b
commit c46b2609d9
1 changed files with 15 additions and 9 deletions

View File

@ -129,19 +129,25 @@ impl Logger {
pub fn custom_request_replace( pub fn custom_request_replace(
mut self, mut self,
label: &'static str, label: &'static str,
closure: impl Fn(&ServiceRequest) -> String + 'static + Clone, closure: impl Fn(&ServiceRequest) -> String + 'static,
) -> Self { ) -> Self {
let inner = Rc::get_mut(&mut self.0).unwrap(); let inner = Rc::get_mut(&mut self.0).unwrap();
for tf in inner.format.0.iter_mut() { let pos = inner.format.0.iter().position(|tf| match tf {
if let FormatText::CustomLog(inner_label, inner_closure) = tf { FormatText::CustomLog(inner_label, _) => label == inner_label,
if inner_label == label { _ => false,
});
match pos {
Some(pos) => match &mut inner.format.0[pos] {
FormatText::CustomLog(_, inner_closure) => {
*inner_closure = Some(CustomRequestFn { *inner_closure = Some(CustomRequestFn {
inner_fn: Rc::new(closure.clone()), inner_fn: Rc::new(closure),
}); })
}; }
}; _ => unreachable!(),
} },
None => (),
};
self self
} }
} }