From 3c8530d95617a1d80b3a125e40fdde69db30eeab Mon Sep 17 00:00:00 2001 From: Jake McGinty Date: Wed, 23 Jun 2021 16:11:37 +0900 Subject: [PATCH] shared: add with_root method in CidrTree --- shared/src/types.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/shared/src/types.rs b/shared/src/types.rs index 4950647..e5b5bcf 100644 --- a/shared/src/types.rs +++ b/shared/src/types.rs @@ -217,7 +217,7 @@ impl Deref for Cidr { } } -#[derive(PartialEq, PartialOrd, Eq, Ord)] +#[derive(Clone, PartialEq, PartialOrd, Eq, Ord)] pub struct CidrTree<'a> { cidrs: &'a [Cidr], contents: &'a Cidr, @@ -237,6 +237,10 @@ impl<'a> CidrTree<'a> { .iter() .min_by_key(|c| c.cidr.prefix()) .expect("failed to find root CIDR"); + Self::with_root(cidrs, root) + } + + pub fn with_root(cidrs: &'a [Cidr], root: &'a Cidr) -> Self { Self { cidrs, contents: root,