From 9934455d4c1857b22a6f54105e54d241f5f61871 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Mon, 10 Apr 2023 07:23:29 +0000 Subject: refactor(partial): into trait --- src/handler/partial.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/handler') diff --git a/src/handler/partial.rs b/src/handler/partial.rs index 1d55b93..aa433e1 100644 --- a/src/handler/partial.rs +++ b/src/handler/partial.rs @@ -18,6 +18,13 @@ use crate::context::RouteContext; -pub trait Partial: FnMut(RouteContext) -> String + Send + Sync {} +#[allow(clippy::module_name_repetitions)] +pub trait Partial: Send + Sync { + fn call(&mut self, context: RouteContext) -> String; +} -impl Partial for T where T: FnMut(RouteContext) -> String + Send + Sync {} +impl Partial for T +where T: FnMut(RouteContext) -> String + Send + Sync +{ + fn call(&mut self, context: RouteContext) -> String { (*self)(context) } +} -- cgit v1.2.3