1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
//! Concept-check helpers — call these in unit tests next to your type
//! to surface adaptation errors close to the source.
//!
//! Mirrors `boost::geometry::concepts::check<T>()` from
//! `boost/geometry/geometries/concepts/check.hpp` and the per-concept
//! `*_concept.hpp` files. Each helper has an empty body — the trait
//! bound *is* the check. Wiring it into a unit test next to the type
//! definition makes the compiler report the adaptation error against
//! that unit test line, not against the algorithm call site that
//! happened to be the first thing to instantiate the bound.
//!
//! See `boost/geometry/test/concepts/point_well_formed*.cpp` for the
//! positive Boost counterparts and
//! `boost/geometry/test/concepts/point_without_*.cpp` for the
//! compile-fail counterparts that the `tests/ui/*` fixtures mirror.
//!
//! # Examples
//!
//! ```
//! use geometry_cs::Cartesian;
//! use geometry_tag::PointTag;
//! use geometry_trait::{check_point, Geometry, Point};
//!
//! #[derive(Default)]
//! struct Xy { x: f64, y: f64 }
//! impl Geometry for Xy { type Kind = PointTag; type Point = Self; }
//! impl Point for Xy {
//! type Scalar = f64; type Cs = Cartesian; const DIM: usize = 2;
//! fn get<const D: usize>(&self) -> f64 { if D == 0 { self.x } else { self.y } }
//! }
//!
//! // Compile-time check that `Xy` correctly models the `Point` concept.
//! check_point::<Xy>();
//! ```
use crate::;
/// Call this in a unit test next to your type definition to surface
/// adaptation errors close to the source rather than at the algorithm
/// call site.
///
/// Mirrors `boost::geometry::concepts::check<Point>()` from
/// `boost/geometry/geometries/concepts/check.hpp` instantiated with
/// the point-concept specialisation in
/// `boost/geometry/geometries/concepts/point_concept.hpp`.
///
/// # Examples
///
/// ```
/// use geometry_trait::check_point;
/// fn _call<P: geometry_trait::Point>() { check_point::<P>(); }
/// ```
/// Call this in a unit test next to your type definition to surface
/// adaptation errors close to the source rather than at the algorithm
/// call site.
///
/// Mirrors `boost::geometry::concepts::check<Segment>()` driven by
/// `boost/geometry/geometries/concepts/segment_concept.hpp`.
///
/// # Examples
///
/// ```
/// use geometry_trait::check_segment;
/// fn _call<S: geometry_trait::Segment>() { check_segment::<S>(); }
/// ```
/// Call this in a unit test next to your type definition to surface
/// adaptation errors close to the source rather than at the algorithm
/// call site.
///
/// Mirrors `boost::geometry::concepts::check<Box>()` driven by
/// `boost/geometry/geometries/concepts/box_concept.hpp`.
///
/// # Examples
///
/// ```
/// use geometry_trait::check_box;
/// fn _call<B: geometry_trait::Box>() { check_box::<B>(); }
/// ```
/// Call this in a unit test next to your type definition to surface
/// adaptation errors close to the source rather than at the algorithm
/// call site.
///
/// Mirrors `boost::geometry::concepts::check<Linestring>()` driven by
/// `boost/geometry/geometries/concepts/linestring_concept.hpp`.
///
/// # Examples
///
/// ```
/// use geometry_trait::check_linestring;
/// fn _call<L: geometry_trait::Linestring>() { check_linestring::<L>(); }
/// ```
/// Call this in a unit test next to your type definition to surface
/// adaptation errors close to the source rather than at the algorithm
/// call site.
///
/// Mirrors `boost::geometry::concepts::check<Ring>()` driven by
/// `boost/geometry/geometries/concepts/ring_concept.hpp`.
///
/// # Examples
///
/// ```
/// use geometry_trait::check_ring;
/// fn _call<R: geometry_trait::Ring>() { check_ring::<R>(); }
/// ```
/// Call this in a unit test next to your type definition to surface
/// adaptation errors close to the source rather than at the algorithm
/// call site.
///
/// Mirrors `boost::geometry::concepts::check<Polygon>()` driven by
/// `boost/geometry/geometries/concepts/polygon_concept.hpp`.
///
/// # Examples
///
/// ```
/// use geometry_trait::check_polygon;
/// fn _call<P: geometry_trait::Polygon>() { check_polygon::<P>(); }
/// ```
/// Call this in a unit test next to your type definition to surface
/// adaptation errors close to the source rather than at the algorithm
/// call site.
///
/// Mirrors `boost::geometry::concepts::check<MultiPoint>()` driven by
/// `boost/geometry/geometries/concepts/multi_point_concept.hpp`.
///
/// # Examples
///
/// ```
/// use geometry_trait::check_multi_point;
/// fn _call<M: geometry_trait::MultiPoint>() { check_multi_point::<M>(); }
/// ```
/// Call this in a unit test next to your type definition to surface
/// adaptation errors close to the source rather than at the algorithm
/// call site.
///
/// Mirrors `boost::geometry::concepts::check<MultiLinestring>()`
/// driven by
/// `boost/geometry/geometries/concepts/multi_linestring_concept.hpp`.
///
/// # Examples
///
/// ```
/// use geometry_trait::check_multi_linestring;
/// fn _call<M: geometry_trait::MultiLinestring>() { check_multi_linestring::<M>(); }
/// ```
/// Call this in a unit test next to your type definition to surface
/// adaptation errors close to the source rather than at the algorithm
/// call site.
///
/// Mirrors `boost::geometry::concepts::check<MultiPolygon>()` driven
/// by `boost/geometry/geometries/concepts/multi_polygon_concept.hpp`.
///
/// # Examples
///
/// ```
/// use geometry_trait::check_multi_polygon;
/// fn _call<M: geometry_trait::MultiPolygon>() { check_multi_polygon::<M>(); }
/// ```
/// Call this in a unit test next to your type definition to surface
/// adaptation errors close to the source rather than at the algorithm
/// call site.
///
/// Mirrors the geometry-collection arm of
/// `boost::geometry::concepts::check<T>()` (see
/// `boost/geometry/geometries/concepts/check.hpp`).
///
/// # Examples
///
/// ```
/// use geometry_trait::check_geometry_collection;
/// fn _call<C: geometry_trait::GeometryCollection>() { check_geometry_collection::<C>(); }
/// ```
/// Call this in a unit test next to your type definition to surface
/// adaptation errors close to the source rather than at the algorithm
/// call site.
///
/// Mirrors the polyhedral-surface arm of
/// `boost::geometry::concepts::check<T>()` (see
/// `boost/geometry/geometries/concepts/check.hpp`).
///
/// # Examples
///
/// ```
/// use geometry_trait::check_polyhedral_surface;
/// fn _call<P: geometry_trait::PolyhedralSurface>() { check_polyhedral_surface::<P>(); }
/// ```
/// Call this in a unit test next to your type definition to surface
/// adaptation errors close to the source rather than at the algorithm
/// call site.
///
/// Generic checker for impls of [`IndexedAccess`] — useful when a
/// custom geometry needs the `(I, D)` two-axis access but is neither a
/// [`Box`] nor a [`Segment`].
///
/// # Examples
///
/// ```
/// use geometry_trait::check_indexed_access;
/// fn _call<G: geometry_trait::IndexedAccess>() { check_indexed_access::<G>(); }
/// ```