src/loc.rs

branch
dev
changeset 166
20fa28637737
parent 164
fd9dba51afd3
child 171
fa8df5a14486
--- a/src/loc.rs	Wed Sep 03 12:55:27 2025 -0500
+++ b/src/loc.rs	Wed Sep 03 13:15:32 2025 -0500
@@ -4,11 +4,12 @@
 */
 
 use crate::euclidean::*;
-use crate::instance::{BasicDecomposition, Instance, MyCow, Ownable};
+use crate::instance::{BasicDecomposition, Instance};
 use crate::linops::{Linear, Mapping, VectorSpace, AXPY};
 use crate::mapping::Space;
 use crate::maputil::{map1, map1_mut, map2, map2_mut, FixedLength, FixedLengthMut};
 use crate::norms::*;
+use crate::self_ownable;
 use crate::types::{Float, Num, SignedNum};
 use serde::ser::{Serialize, SerializeSeq, Serializer};
 use std::fmt::{Display, Formatter};
@@ -27,28 +28,7 @@
     pub [F; N],
 );
 
-/// Trait for ownable-by-consumption objects
-impl<const N: usize, F: Copy> Ownable for Loc<N, F> {
-    type OwnedVariant = Self;
-
-    #[inline]
-    fn into_owned(self) -> Self::OwnedVariant {
-        self
-    }
-
-    /// Returns an owned instance of a reference.
-    fn clone_owned(&self) -> Self::OwnedVariant {
-        self.clone()
-    }
-
-    /// Returns an owned instance of a reference.
-    fn cow_owned<'b>(self) -> MyCow<'b, Self::OwnedVariant>
-    where
-        Self: 'b,
-    {
-        MyCow::Owned(self)
-    }
-}
+self_ownable!(Loc<N, F> where const N: usize, F: Copy);
 
 impl<F: Display, const N: usize> Display for Loc<N, F> {
     // Required method

mercurial