Merge pull request #1156 from dimforge/fix-ci

Add a non-const version of Point::new when the cuda feature is enabled
This commit is contained in:
Sébastien Crozet 2022-09-24 10:35:15 +02:00 committed by GitHub
commit 202a548a37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 31 additions and 0 deletions

View File

@ -202,11 +202,29 @@ impl<T: Scalar> Point1<T> {
/// assert_eq!(p.x, 1.0); /// assert_eq!(p.x, 1.0);
/// ``` /// ```
#[inline] #[inline]
#[cfg(not(feature = "cuda"))]
pub const fn new(x: T) -> Self { pub const fn new(x: T) -> Self {
Point { Point {
coords: Vector1::new(x), 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( macro_rules! componentwise_constructors_impl(
($($doc: expr; $Point: ident, $Vector: ident, $($args: ident:$irow: expr),*);* $(;)*) => {$( ($($doc: expr; $Point: ident, $Vector: ident, $($args: ident:$irow: expr),*);* $(;)*) => {$(
@ -216,9 +234,22 @@ macro_rules! componentwise_constructors_impl(
#[doc = $doc] #[doc = $doc]
#[doc = "```"] #[doc = "```"]
#[inline] #[inline]
#[cfg(not(feature = "cuda"))]
pub const fn new($($args: T),*) -> Self { pub const fn new($($args: T),*) -> Self {
Point { coords: $Vector::new($($args),*) } 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),*) }
}
} }
)*} )*}
); );