Skip to content

Commit

Permalink
Add placeholder From<Area> impl for Range, crate imports, core::cmp::min
Browse files Browse the repository at this point in the history
  • Loading branch information
sgwilym committed Jun 24, 2024
1 parent 965f565 commit 67b7f91
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
5 changes: 0 additions & 5 deletions data-model/src/grouping/area.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,6 @@ impl<S: SubspaceId, P: Path> Area<S, P> {
path,
})
}

/// Return a [`Range3d`] with equivalent inclusion to this [`Area`].
pub fn into_range(&self) -> Range3d<S, P> {
todo!("Need to add successor fns to SubspaceId and Paths first.")
}
}

#[cfg(test)]
Expand Down
6 changes: 2 additions & 4 deletions data-model/src/grouping/area_of_interest.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use crate::{parameters::SubspaceId, path::Path};

use super::area::Area;
use crate::{grouping::area::Area, parameters::SubspaceId, path::Path};

/// A grouping of [`Entry`]s that are among the newest in some [`Store`].
/// [Definition](https://willowprotocol.org/specs/grouping-entries/index.html#aois).
Expand All @@ -21,7 +19,7 @@ impl<S: SubspaceId, P: Path> AreaOfInterest<S, P> {
None => None,
Some(area_intersection) => Some(Self {
area: area_intersection,
max_count: self.max_count.min(other.max_count),
max_count: core::cmp::min(self.max_count, other.max_count),
max_size: self.max_size.min(other.max_size),
}),
}
Expand Down
10 changes: 8 additions & 2 deletions data-model/src/grouping/range_3d.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::range::Range;
use crate::{
entry::{Entry, Timestamp},
grouping::{area::Area, range::Range},
parameters::{NamespaceId, PayloadDigest, SubspaceId},
path::Path,
};
Expand Down Expand Up @@ -48,13 +48,19 @@ impl<S: SubspaceId, P: Path> Default for Range3d<S, P> {
/// [Definition](https://willowprotocol.org/specs/grouping-entries/index.html#default_3d_range).
fn default() -> Self {
Self {
subspaces: Default::default(),
subspaces: Range::<S>::default(),
paths: Range::new_open(P::empty()),
times: Range::new_open(0),
}
}
}

impl<S: SubspaceId, P: Path> From<Area<S, P>> for Range3d<S, P> {
fn from(_value: Area<S, P>) -> Self {
todo!("Need to add successor fns to SubspaceId and Paths first.")
}
}

#[cfg(test)]
mod tests {
use crate::path::{PathComponent, PathComponentBox, PathRc};
Expand Down
2 changes: 1 addition & 1 deletion data-model/src/parameters.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::{entry::Entry, path::Path};
use crate::{entry::Entry, path::Path};

/// A type for identifying [namespaces](https://willowprotocol.org/specs/data-model/index.html#namespace).
/// [Definition](https://willowprotocol.org/specs/data-model/index.html#NamespaceId).
Expand Down
2 changes: 1 addition & 1 deletion data-model/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ impl<const MCL: usize, const MCC: usize, const MPL: usize> Path for PathRc<MCL,
return Self::empty();
}

let until = std::cmp::min(length, self.0.len());
let until = core::cmp::min(length, self.0.len());
let slice = &self.0[0..until];

Path::new(slice).unwrap()
Expand Down

0 comments on commit 67b7f91

Please sign in to comment.