--- a/src/instance.rs Wed Sep 03 14:27:21 2025 -0500 +++ b/src/instance.rs Wed Sep 03 17:59:24 2025 -0500 @@ -321,8 +321,7 @@ /// generalises [`std::borrow::ToOwned`], [`std::borrow::Borrow`], and [`std::borrow::Cow`]. /// /// This is used, for example, by [`crate::mapping::Mapping::apply`]. -pub trait Instance<X, D = <X as Space>::Decomp>: - Sized + Ownable<OwnedVariant = X::Principal> +pub trait Instance<X, D = <X as Space>::Decomp>: Sized where X: Space, D: Decomposition<X>, @@ -342,21 +341,14 @@ Self: 'b; /// Returns an owned instance of `X`, cloning or converting non-true instances when necessary. - fn own(self) -> X::Principal { - self.into_owned() - } - - // ************** automatically implemented methods below from here ************** + fn own(self) -> X::Principal; /// Returns an owned instance or reference to `X`, converting non-true instances when necessary. /// /// Default implementation uses [`Self::own`]. Consumes the input. fn cow<'b>(self) -> MyCow<'b, X::Principal> where - Self: 'b, - { - self.cow_owned() - } + Self: 'b; #[inline] /// Evaluates `f` on a reference to self. @@ -407,6 +399,19 @@ { f(self) } + + #[inline] + fn own(self) -> X::Principal { + self.into_owned() + } + + #[inline] + fn cow<'b>(self) -> MyCow<'b, X::Principal> + where + Self: 'b, + { + self.cow_owned() + } } impl<'a, X: Space> Instance<X, BasicDecomposition> for &'a X { @@ -427,6 +432,19 @@ { f(*self) } + + #[inline] + fn own(self) -> X::Principal { + self.into_owned() + } + + #[inline] + fn cow<'b>(self) -> MyCow<'b, X::Principal> + where + Self: 'b, + { + self.cow_owned() + } } impl<'a, X: Space> Instance<X, BasicDecomposition> for &'a mut X { @@ -447,6 +465,19 @@ { f(*self) } + + #[inline] + fn own(self) -> X::Principal { + self.into_owned() + } + + #[inline] + fn cow<'b>(self) -> MyCow<'b, X::Principal> + where + Self: 'b, + { + self.cow_owned() + } } impl<'a, X: Space> Instance<X, BasicDecomposition> for MyCow<'a, X> { @@ -470,6 +501,19 @@ MyCow::Owned(b) => f(&b), } } + + #[inline] + fn own(self) -> X::Principal { + self.into_owned() + } + + #[inline] + fn cow<'b>(self) -> MyCow<'b, X::Principal> + where + Self: 'b, + { + self.cow_owned() + } } /// Marker type for mutable decompositions to be used with [`InstanceMut`].