Skip to content

Commit

Permalink
make PathTree & Node cloneable (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
fundon authored Dec 25, 2023
1 parent b55432b commit 6566800
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> {
id: usize,
routes: Vec<(T, Vec<Piece>)>,
Expand Down Expand Up @@ -208,7 +207,7 @@ impl<T> PathTree<T> {
}
}

/// 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();
Expand Down
1 change: 1 addition & 0 deletions src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub enum Key {
Parameter(Kind),
}

#[derive(Clone)]
pub struct Node<T> {
pub key: Key,
pub value: Option<T>,
Expand Down

0 comments on commit 6566800

Please sign in to comment.