From 1c1a087d5b90dcedf0ecad03c07be1bcb62baffa Mon Sep 17 00:00:00 2001 From: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> Date: Thu, 31 Oct 2024 11:59:34 +0100 Subject: [PATCH] feat: Allow creating an empty `Params` instance. --- src/params.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/params.rs b/src/params.rs index 625b544..922b7bb 100644 --- a/src/params.rs +++ b/src/params.rs @@ -51,6 +51,12 @@ pub struct Params<'k, 'v> { kind: ParamsKind<'k, 'v>, } +impl Default for Params<'_, '_> { + fn default() -> Self { + Self::new() + } +} + // Most routes have a small number of dynamic parameters, so we can avoid // heap allocations in the common case. const SMALL: usize = 3; @@ -63,7 +69,8 @@ enum ParamsKind<'k, 'v> { } impl<'k, 'v> Params<'k, 'v> { - pub(crate) fn new() -> Self { + /// Create an empty list of parameters. + pub fn new() -> Self { Self { kind: ParamsKind::Small([Param::EMPTY; 3], 0), }