diff options
| author | Fuwn <[email protected]> | 2023-04-10 07:23:29 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2023-04-10 07:23:29 +0000 |
| commit | 9934455d4c1857b22a6f54105e54d241f5f61871 (patch) | |
| tree | c0e4165c7ea43200fbeae6d472dc036c58b1079e /src/handler/partial.rs | |
| parent | fix(macros): restrict macro name (diff) | |
| download | windmark-9934455d4c1857b22a6f54105e54d241f5f61871.tar.xz windmark-9934455d4c1857b22a6f54105e54d241f5f61871.zip | |
refactor(partial): into trait
Diffstat (limited to 'src/handler/partial.rs')
| -rw-r--r-- | src/handler/partial.rs | 11 |
1 files changed, 9 insertions, 2 deletions
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<T> Partial for T where T: FnMut(RouteContext) -> String + Send + Sync {} +impl<T> Partial for T +where T: FnMut(RouteContext) -> String + Send + Sync +{ + fn call(&mut self, context: RouteContext) -> String { (*self)(context) } +} |