#[repr(transparent)]pub struct WithCs<T, Cs: CoordinateSystem> {
pub inner: T,
/* private fields */
}Expand description
Re-tag any Point with a different coordinate system, without
changing its storage layout.
Zero-cost: #[repr(transparent)] plus pure forwarding impls
means &WithCs<T, Cs> is layout-compatible with &T and
monomorphises to identical code. Only the Cs associated type
of the Point impl changes — Scalar, DIM, get, and
set all forward to the inner point.
See proposal §3.7 for the design rationale (orthogonality of shape vs. coordinate system, and the silent-Cartesian risk mitigation that lives in T31).
§Example
use geometry_adapt::{Adapt, WithCs};
use geometry_cs::{Degree, Geographic};
use geometry_trait::Point;
// An [f64; 2] adapted as a Cartesian point, then re-tagged as
// a geographic lat/lon pair in degrees.
let p: WithCs<Adapt<[f64; 2]>, Geographic<Degree>> =
WithCs::new(Adapt([4.9, 52.4]));
assert_eq!(p.get::<0>(), 4.9);
assert_eq!(p.get::<1>(), 52.4);Fields§
§inner: TThe wrapped inner point. Public so call sites can read or mutate the foreign storage directly when convenient.
Implementations§
Source§impl<T, Cs: CoordinateSystem> WithCs<T, Cs>
impl<T, Cs: CoordinateSystem> WithCs<T, Cs>
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Unwrap, returning the inner point.
Trait Implementations§
impl<T: Copy, Cs: Copy + CoordinateSystem> Copy for WithCs<T, Cs>
impl<T: Eq, Cs: Eq + CoordinateSystem> Eq for WithCs<T, Cs>
impl<T: PartialEq, Cs: PartialEq + CoordinateSystem> StructuralPartialEq for WithCs<T, Cs>
Auto Trait Implementations§
impl<T, Cs> Freeze for WithCs<T, Cs>where
T: Freeze,
impl<T, Cs> RefUnwindSafe for WithCs<T, Cs>where
T: RefUnwindSafe,
Cs: RefUnwindSafe,
impl<T, Cs> Send for WithCs<T, Cs>
impl<T, Cs> Sync for WithCs<T, Cs>
impl<T, Cs> Unpin for WithCs<T, Cs>
impl<T, Cs> UnsafeUnpin for WithCs<T, Cs>where
T: UnsafeUnpin,
impl<T, Cs> UnwindSafe for WithCs<T, Cs>where
T: UnwindSafe,
Cs: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more