geo/algorithm/sweep/
cross.rs1use std::{fmt::Debug, rc::Rc, sync::Arc};
2
3use geo_types::Line;
4
5use super::*;
6use crate::GeoFloat;
7
8pub trait Cross: Sized + Debug {
21 type Scalar: GeoFloat;
23
24 fn line(&self) -> LineOrPoint<Self::Scalar>;
27}
28
29impl<'a, T: Cross> Cross for &'a T {
30 type Scalar = T::Scalar;
31
32 fn line(&self) -> LineOrPoint<Self::Scalar> {
33 T::line(*self)
34 }
35}
36
37impl<T: GeoFloat> Cross for LineOrPoint<T> {
38 type Scalar = T;
39
40 fn line(&self) -> LineOrPoint<Self::Scalar> {
41 *self
42 }
43}
44
45impl<T: GeoFloat> Cross for Line<T> {
46 type Scalar = T;
47
48 fn line(&self) -> LineOrPoint<Self::Scalar> {
49 (*self).into()
50 }
51}
52
53macro_rules! blanket_impl_smart_pointer {
54 ($ty:ty) => {
55 impl<T: Cross> Cross for $ty {
56 type Scalar = T::Scalar;
57
58 fn line(&self) -> LineOrPoint<Self::Scalar> {
59 T::line(self)
60 }
61 }
62 };
63}
64blanket_impl_smart_pointer!(Box<T>);
65blanket_impl_smart_pointer!(Rc<T>);
66blanket_impl_smart_pointer!(Arc<T>);