diff --git a/README.md b/README.md index d228d74..a99fe35 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # QuadTree motivation -This repo implements a QuadTree (more correctly, an orthtree) in Rust. It is generic over the number of dimensions, the type of data stored, and the shape of the region being queried. Any struct that implements `Storable` can be inserted. When querying, pass in any region that implements `Query`. +This repo implements a QuadTree (more correctly, an orthtree) in Rust. It is generic over the number of dimensions, the type of data stored, and the shape of the region being queried. Any struct that is `Storable` can be inserted. When querying, pass in any region that is `Query`. `Point` is automatically `Storable` # Usage @@ -19,7 +19,7 @@ let region = Region::new(&[ // it implements the Storable trait. // Here we're deferring the type of the QuadTree to the compiler, // inferred from the first insert -let mut quadtree = QuadTree::new(®ion, NonZero::new(4).unwrap()); +let mut quadtree = QuadTree::new(®ion, NonZero::new(4).expect("4 is non-zero")); // Insert points into the QuadTree for i in 0..4 { @@ -41,4 +41,4 @@ assert_eq!(results.len(), 2); To run the `nannou` app, run `cargo run --bin visualize`. -![](assets/vis.gif) \ No newline at end of file +![](assets/vis.gif) diff --git a/quadtree/src/quadtree.rs b/quadtree/src/quadtree.rs index cc6f7c5..6fd2796 100644 --- a/quadtree/src/quadtree.rs +++ b/quadtree/src/quadtree.rs @@ -23,17 +23,17 @@ pub trait Storable { /// ]); /// /// // Initialise the QuadTree with this region and the maximum number of points each individual node -/// // should store. You can store any Struct in the QuadTree as long as it implements the Storable trait. +/// // should store. /// // Here we're deferring the type of the QuadTree to the compiler, -/// // inferred from the first insert -/// let mut quadtree = QuadTree::new(®ion, NonZero::new(4).ok_or_eyre("value must be > 0")?); +/// // inferred from the first insert of a [Storable] item. +/// let mut quadtree = QuadTree::new(®ion, NonZero::new(4).expect("4 is non-zero")); /// -/// // Insert points into the QuadTree +/// // Insert points into the QuadTree. You can insert any type that is [Storable]. /// for i in 0..4 { /// quadtree.insert(Point::new(&[i, 0]))?; /// } /// -/// // To query the QuadTree, provide a region, or anything that implements the Query trait +/// // To query the QuadTree, provide a region, or anything that is [Query] /// let query_region = Region::new(&[ /// Interval::try_new(0.0, 2.0)?, /// Interval::try_new(0.0, 10.0)?,