From 1079f0c1c395f9c1d8f7a66eaff979f64ac4bed3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Crozet?= Date: Sat, 24 Sep 2022 09:50:58 +0200 Subject: [PATCH 1/2] Add a non-const version of Point::new when the cuda feature is enabled --- src/geometry/point_construction.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/geometry/point_construction.rs b/src/geometry/point_construction.rs index ac54b349f..c061b8721 100644 --- a/src/geometry/point_construction.rs +++ b/src/geometry/point_construction.rs @@ -216,9 +216,22 @@ macro_rules! componentwise_constructors_impl( #[doc = $doc] #[doc = "```"] #[inline] + #[cfg(not(feature = "cuda"))] pub const fn new($($args: T),*) -> Self { Point { coords: $Vector::new($($args),*) } } + + // TODO: always let new be const once CUDA updates its supported + // nightly version to something more recent. + #[doc = "Initializes this point from its components."] + #[doc = "# Example\n```"] + #[doc = $doc] + #[doc = "```"] + #[inline] + #[cfg(feature = "cuda")] + pub fn new($($args: T),*) -> Self { + Point { coords: $Vector::new($($args),*) } + } } )*} ); From 1870080f94e0d5b0374e88a565871b55e562619b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Crozet?= Date: Sat, 24 Sep 2022 10:13:15 +0200 Subject: [PATCH 2/2] Remove const for Point1::new when targetting cuda --- src/geometry/point_construction.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/geometry/point_construction.rs b/src/geometry/point_construction.rs index c061b8721..598cf4edf 100644 --- a/src/geometry/point_construction.rs +++ b/src/geometry/point_construction.rs @@ -202,11 +202,29 @@ impl Point1 { /// assert_eq!(p.x, 1.0); /// ``` #[inline] + #[cfg(not(feature = "cuda"))] pub const fn new(x: T) -> Self { Point { coords: Vector1::new(x), } } + + /// Initializes this point from its components. + /// + /// # Example + /// + /// ``` + /// # use nalgebra::Point1; + /// let p = Point1::new(1.0); + /// assert_eq!(p.x, 1.0); + /// ``` + #[inline] + #[cfg(feature = "cuda")] + pub fn new(x: T) -> Self { + Point { + coords: Vector1::new(x), + } + } } macro_rules! componentwise_constructors_impl( ($($doc: expr; $Point: ident, $Vector: ident, $($args: ident:$irow: expr),*);* $(;)*) => {$(