|
| 1 | +use alloc::rc::Rc; |
| 2 | +use alloc::sync::Arc; |
| 3 | + |
1 | 4 | use crate::aabb::AABB; |
2 | 5 | use crate::envelope::Envelope; |
3 | 6 | use crate::point::{Point, PointExt}; |
@@ -232,3 +235,61 @@ where |
232 | 235 | } |
233 | 236 | } |
234 | 237 | } |
| 238 | + |
| 239 | +impl<T> RTreeObject for Arc<T> |
| 240 | +where |
| 241 | + T: RTreeObject + ?Sized, |
| 242 | +{ |
| 243 | + type Envelope = T::Envelope; |
| 244 | + fn envelope(&self) -> Self::Envelope { |
| 245 | + (**self).envelope() |
| 246 | + } |
| 247 | +} |
| 248 | + |
| 249 | +impl<T> PointDistance for Arc<T> |
| 250 | +where |
| 251 | + T: PointDistance + ?Sized, |
| 252 | +{ |
| 253 | + fn distance_2(&self, point: &<Self::Envelope as Envelope>::Point) -> Distance<Self> { |
| 254 | + (**self).distance_2(point) |
| 255 | + } |
| 256 | + fn contains_point(&self, point: &<Self::Envelope as Envelope>::Point) -> bool { |
| 257 | + (**self).contains_point(point) |
| 258 | + } |
| 259 | + fn distance_2_if_less_or_equal( |
| 260 | + &self, |
| 261 | + point: &<Self::Envelope as Envelope>::Point, |
| 262 | + max_distance_2: Distance<Self>, |
| 263 | + ) -> Option<Distance<Self>> { |
| 264 | + (**self).distance_2_if_less_or_equal(point, max_distance_2) |
| 265 | + } |
| 266 | +} |
| 267 | + |
| 268 | +impl<T> RTreeObject for Rc<T> |
| 269 | +where |
| 270 | + T: RTreeObject + ?Sized, |
| 271 | +{ |
| 272 | + type Envelope = T::Envelope; |
| 273 | + fn envelope(&self) -> Self::Envelope { |
| 274 | + (**self).envelope() |
| 275 | + } |
| 276 | +} |
| 277 | + |
| 278 | +impl<T> PointDistance for Rc<T> |
| 279 | +where |
| 280 | + T: PointDistance + ?Sized, |
| 281 | +{ |
| 282 | + fn distance_2(&self, point: &<Self::Envelope as Envelope>::Point) -> Distance<Self> { |
| 283 | + (**self).distance_2(point) |
| 284 | + } |
| 285 | + fn contains_point(&self, point: &<Self::Envelope as Envelope>::Point) -> bool { |
| 286 | + (**self).contains_point(point) |
| 287 | + } |
| 288 | + fn distance_2_if_less_or_equal( |
| 289 | + &self, |
| 290 | + point: &<Self::Envelope as Envelope>::Point, |
| 291 | + max_distance_2: Distance<Self>, |
| 292 | + ) -> Option<Distance<Self>> { |
| 293 | + (**self).distance_2_if_less_or_equal(point, max_distance_2) |
| 294 | + } |
| 295 | +} |
0 commit comments