From d7c4ef5dd756c97a36435389bcc39e75ff7dcbf0 Mon Sep 17 00:00:00 2001 From: Floris Bruynooghe Date: Mon, 25 Mar 2024 11:13:07 +0100 Subject: [PATCH] Make this work in tests --- iroh-sync/src/ranger.rs | 14 ++++++++------ iroh-sync/src/sync.rs | 7 ++++--- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/iroh-sync/src/ranger.rs b/iroh-sync/src/ranger.rs index 0e63a5f73a..2199ff8f6f 100644 --- a/iroh-sync/src/ranger.rs +++ b/iroh-sync/src/ranger.rs @@ -40,13 +40,15 @@ pub trait RangeEntry: Debug + Clone { /// A trait constraining types that are valid entry keys. pub trait RangeKey: Sized + Debug + Ord + PartialEq + Clone + 'static { - // /// Returns `true` if `self` is a prefix of `other`. - // fn is_prefix_of(&self, other: &Self) -> bool; + /// Returns `true` if `self` is a prefix of `other`. + #[cfg(test)] + fn is_prefix_of(&self, other: &Self) -> bool; - // /// Returns true if `other` is a prefix of `self`. - // fn is_prefixed_by(&self, other: &Self) -> bool { - // other.is_prefix_of(self) - // } + /// Returns true if `other` is a prefix of `self`. + #[cfg(test)] + fn is_prefixed_by(&self, other: &Self) -> bool { + other.is_prefix_of(self) + } } /// A trait constraining types that are valid entry values. diff --git a/iroh-sync/src/sync.rs b/iroh-sync/src/sync.rs index 03d9a7f388..9f9fe727e1 100644 --- a/iroh-sync/src/sync.rs +++ b/iroh-sync/src/sync.rs @@ -974,9 +974,10 @@ impl Debug for RecordIdentifier { } impl RangeKey for RecordIdentifier { - // fn is_prefix_of(&self, other: &Self) -> bool { - // other.as_ref().starts_with(self.as_ref()) - // } + #[cfg(test)] + fn is_prefix_of(&self, other: &Self) -> bool { + other.as_ref().starts_with(self.as_ref()) + } } fn system_time_now() -> u64 {