From 891858c4c2b4657864fa07a4814551e4c1289ce4 Mon Sep 17 00:00:00 2001 From: Fangdun Tsai Date: Mon, 25 Dec 2023 09:35:14 +0800 Subject: [PATCH] make PathTree & Node cloneable --- src/lib.rs | 9 ++++----- src/node.rs | 1 + 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 079966a..add1c28 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -143,17 +143,16 @@ use alloc::{ vec::Vec, }; use core::str::from_utf8; - use smallvec::SmallVec; mod node; -mod parser; - pub use node::{Key, Node}; + +mod parser; pub use parser::{Kind, Parser, Piece, Position}; /// A path tree. -#[derive(Debug)] +#[derive(Clone, Debug)] pub struct PathTree { id: usize, routes: Vec<(T, Vec)>, @@ -208,7 +207,7 @@ impl PathTree { } } - /// Returns the [Path] by the given path. + /// Returns the [`Path`] by the given path. #[must_use] pub fn find<'a, 'b>(&'a self, path: &'b str) -> Option<(&T, Path<'a, 'b>)> { let bytes = path.as_bytes(); diff --git a/src/node.rs b/src/node.rs index e3888df..b6131c3 100644 --- a/src/node.rs +++ b/src/node.rs @@ -15,6 +15,7 @@ pub enum Key { Parameter(Kind), } +#[derive(Clone)] pub struct Node { pub key: Key, pub value: Option,