Skip to content

Commit 5e7a37a

Browse files
committed
Use M for metadata docs and helpers
1 parent 019ab69 commit 5e7a37a

6 files changed

Lines changed: 121 additions & 109 deletions

File tree

readme.md

Lines changed: 90 additions & 90 deletions
Large diffs are not rendered by default.

src/bmesh/mod.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub struct BMesh<M: Clone + Send + Sync + Debug> {
2828
pub manifold: Option<Manifold>,
2929
/// Lazily computed Parry AABB for the solid.
3030
pub bounding_box: OnceLock<Aabb>,
31-
/// Whole-shape metadata. Use `M = ()` for no metadata and `M = Option<T>`
31+
/// Whole-shape metadata. Use `M = ()` for no metadata and `M = Option<YourMetadata>`
3232
/// for optional metadata.
3333
pub metadata: M,
3434
}
@@ -61,7 +61,10 @@ impl<M: Clone + Send + Sync + Debug> BMesh<M> {
6161
}
6262

6363
/// Return this boolmesh wrapper with replacement metadata.
64-
pub fn with_metadata<T: Clone + Send + Sync + Debug>(self, metadata: T) -> BMesh<T> {
64+
pub fn with_metadata<NewM: Clone + Send + Sync + Debug>(
65+
self,
66+
metadata: NewM,
67+
) -> BMesh<NewM> {
6568
BMesh {
6669
manifold: self.manifold,
6770
bounding_box: OnceLock::new(),
@@ -70,9 +73,9 @@ impl<M: Clone + Send + Sync + Debug> BMesh<M> {
7073
}
7174

7275
/// Map this boolmesh wrapper's metadata while preserving geometry.
73-
pub fn map_metadata<T: Clone + Send + Sync + Debug, F>(self, f: F) -> BMesh<T>
76+
pub fn map_metadata<NewM: Clone + Send + Sync + Debug, F>(self, f: F) -> BMesh<NewM>
7477
where
75-
F: FnOnce(M) -> T,
78+
F: FnOnce(M) -> NewM,
7679
{
7780
BMesh {
7881
manifold: self.manifold,

src/mesh/mod.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ pub struct Mesh<M: Clone + Send + Sync + Debug> {
8383
/// Lazily built Parry TriMesh reused by query operations.
8484
pub query_trimesh: OnceLock<Option<TriMesh>>,
8585

86-
/// Whole-mesh metadata. Use `M = ()` for no metadata and `M = Option<T>`
86+
/// Whole-mesh metadata. Use `M = ()` for no metadata and `M = Option<YourMetadata>`
8787
/// for optional metadata.
8888
pub metadata: M,
8989
}
@@ -136,7 +136,10 @@ impl<M: Clone + Send + Sync + Debug> Mesh<M> {
136136
}
137137

138138
/// Return this mesh with replacement metadata on the mesh and every polygon.
139-
pub fn with_metadata<T: Clone + Send + Sync + Debug>(self, metadata: T) -> Mesh<T> {
139+
pub fn with_metadata<NewM: Clone + Send + Sync + Debug>(
140+
self,
141+
metadata: NewM,
142+
) -> Mesh<NewM> {
140143
let polygons = self
141144
.polygons
142145
.into_iter()
@@ -152,9 +155,9 @@ impl<M: Clone + Send + Sync + Debug> Mesh<M> {
152155
}
153156

154157
/// Map metadata on the mesh and every polygon while preserving geometry.
155-
pub fn map_metadata<T: Clone + Send + Sync + Debug, F>(self, mut f: F) -> Mesh<T>
158+
pub fn map_metadata<NewM: Clone + Send + Sync + Debug, F>(self, mut f: F) -> Mesh<NewM>
156159
where
157-
F: FnMut(M) -> T,
160+
F: FnMut(M) -> NewM,
158161
{
159162
let polygons = self
160163
.polygons

src/nurbs/nurbs.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ impl<M: Clone + Send + Sync + Debug> Nurbs<M> {
5656
}
5757

5858
/// Return this NURBS geometry with replacement metadata.
59-
pub fn with_metadata<T: Clone + Send + Sync + Debug>(self, metadata: T) -> Nurbs<T> {
59+
pub fn with_metadata<NewM: Clone + Send + Sync + Debug>(
60+
self,
61+
metadata: NewM,
62+
) -> Nurbs<NewM> {
6063
Nurbs {
6164
regions: self.regions,
6265
bounding_box: OnceLock::new(),
@@ -65,9 +68,9 @@ impl<M: Clone + Send + Sync + Debug> Nurbs<M> {
6568
}
6669

6770
/// Map this NURBS geometry's metadata while preserving its regions.
68-
pub fn map_metadata<T: Clone + Send + Sync + Debug, F>(self, f: F) -> Nurbs<T>
71+
pub fn map_metadata<NewM: Clone + Send + Sync + Debug, F>(self, f: F) -> Nurbs<NewM>
6972
where
70-
F: FnOnce(M) -> T,
73+
F: FnOnce(M) -> NewM,
7174
{
7275
Nurbs {
7376
regions: self.regions,

src/polygon.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::sync::OnceLock;
88

99
/// A polygon, defined by a list of vertices.
1010
/// - `M` is the generic metadata type stored directly on the polygon. Use
11-
/// `M = ()` for no metadata, or `M = Option<T>` for optional metadata.
11+
/// `M = ()` for no metadata, or `M = Option<YourMetadata>` for optional metadata.
1212
#[derive(Debug, Clone)]
1313
pub struct Polygon<M: Clone> {
1414
/// Vertices defining the Polygon's shape
@@ -55,7 +55,7 @@ impl<M: Clone + Send + Sync> Polygon<M> {
5555
}
5656

5757
/// Return this polygon with replacement metadata.
58-
pub fn with_metadata<T: Clone + Send + Sync>(self, metadata: T) -> Polygon<T> {
58+
pub fn with_metadata<NewM: Clone + Send + Sync>(self, metadata: NewM) -> Polygon<NewM> {
5959
Polygon {
6060
vertices: self.vertices,
6161
plane: self.plane,
@@ -65,9 +65,9 @@ impl<M: Clone + Send + Sync> Polygon<M> {
6565
}
6666

6767
/// Map this polygon's metadata while preserving its geometry.
68-
pub fn map_metadata<T: Clone + Send + Sync, F>(self, f: F) -> Polygon<T>
68+
pub fn map_metadata<NewM: Clone + Send + Sync, F>(self, f: F) -> Polygon<NewM>
6969
where
70-
F: FnOnce(M) -> T,
70+
F: FnOnce(M) -> NewM,
7171
{
7272
Polygon {
7373
vertices: self.vertices,

src/sketch/mod.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ pub struct Sketch<M> {
7474
/// Lazily calculated AABB that spans `geometry`.
7575
pub bounding_box: OnceLock<Aabb>,
7676

77-
/// Whole-sketch metadata. Use `M = ()` for no metadata and `M = Option<T>`
77+
/// Whole-sketch metadata. Use `M = ()` for no metadata and `M = Option<YourMetadata>`
7878
/// for optional metadata.
7979
pub metadata: M,
8080

@@ -123,7 +123,10 @@ impl<M: Clone + Send + Sync + Debug> Sketch<M> {
123123
}
124124

125125
/// Return this sketch with replacement metadata.
126-
pub fn with_metadata<T: Clone + Send + Sync + Debug>(self, metadata: T) -> Sketch<T> {
126+
pub fn with_metadata<NewM: Clone + Send + Sync + Debug>(
127+
self,
128+
metadata: NewM,
129+
) -> Sketch<NewM> {
127130
Sketch {
128131
geometry: self.geometry,
129132
bounding_box: OnceLock::new(),
@@ -134,9 +137,9 @@ impl<M: Clone + Send + Sync + Debug> Sketch<M> {
134137
}
135138

136139
/// Map this sketch's metadata while preserving its geometry and origin.
137-
pub fn map_metadata<T: Clone + Send + Sync + Debug, F>(self, f: F) -> Sketch<T>
140+
pub fn map_metadata<NewM: Clone + Send + Sync + Debug, F>(self, f: F) -> Sketch<NewM>
138141
where
139-
F: FnOnce(M) -> T,
142+
F: FnOnce(M) -> NewM,
140143
{
141144
Sketch {
142145
geometry: self.geometry,

0 commit comments

Comments
 (0)