Skip to content

Commit

Permalink
feat: allow creating an empty Params instance
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeMathWalker authored Nov 7, 2024
1 parent 8e66ae9 commit 7e422d9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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),
}
Expand Down

0 comments on commit 7e422d9

Please sign in to comment.