diff --git a/src/geometry/point_construction.rs b/src/geometry/point_construction.rs index ac54b349..598cf4ed 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),*);* $(;)*) => {$( @@ -216,9 +234,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),*) } + } } )*} );