From 7be7fc87763ac26d0e2a2732a833b10f215646ac Mon Sep 17 00:00:00 2001 From: sebcrozet Date: Sun, 3 Feb 2019 15:16:50 +0100 Subject: [PATCH] Fix compilation with no-std. --- src/base/conversion.rs | 4 +++- src/base/edition.rs | 19 +++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/base/conversion.rs b/src/base/conversion.rs index 2e5ca9df..fcb6907d 100644 --- a/src/base/conversion.rs +++ b/src/base/conversion.rs @@ -12,8 +12,10 @@ use typenum::Prod; use base::allocator::{Allocator, SameShapeAllocator}; use base::constraint::{SameNumberOfColumns, SameNumberOfRows, ShapeConstraint}; use base::dimension::{ - Dim, DimName, Dynamic, U1, U10, U11, U12, U13, U14, U15, U16, U2, U3, U4, U5, U6, U7, U8, U9, + Dim, DimName, U1, U10, U11, U12, U13, U14, U15, U16, U2, U3, U4, U5, U6, U7, U8, U9, }; +#[cfg(any(feature = "std", feature = "alloc"))] +use base::dimension::Dynamic; use base::iter::{MatrixIter, MatrixIterMut}; use base::storage::{ContiguousStorage, ContiguousStorageMut, Storage, StorageMut}; #[cfg(any(feature = "std", feature = "alloc"))] diff --git a/src/base/edition.rs b/src/base/edition.rs index 82e5d7ea..32e2c1aa 100644 --- a/src/base/edition.rs +++ b/src/base/edition.rs @@ -1,14 +1,18 @@ use num::{One, Zero}; use std::cmp; use std::ptr; +#[cfg(any(feature = "std", feature = "alloc"))] use std::iter::ExactSizeIterator; +#[cfg(any(feature = "std", feature = "alloc"))] use std::mem; use base::allocator::{Allocator, Reallocator}; use base::constraint::{DimEq, SameNumberOfColumns, SameNumberOfRows, ShapeConstraint}; use base::dimension::{ - Dim, DimAdd, DimDiff, DimMin, DimMinimum, DimName, DimSub, DimSum, Dynamic, U1, + Dim, DimAdd, DimDiff, DimMin, DimMinimum, DimName, DimSub, DimSum, U1, }; +#[cfg(any(feature = "std", feature = "alloc"))] +use base::dimension::Dynamic; use base::storage::{Storage, StorageMut}; #[cfg(any(feature = "std", feature = "alloc"))] use base::DMatrix; @@ -36,6 +40,7 @@ impl> Matrix { } /// Creates a new matrix by extracting the given set of rows from `self`. + #[cfg(any(feature = "std", feature = "alloc"))] pub fn select_rows<'a, I>(&self, irows: I) -> MatrixMN where I: IntoIterator, I::IntoIter: ExactSizeIterator + Clone, @@ -66,6 +71,7 @@ impl> Matrix { } /// Creates a new matrix by extracting the given set of columns from `self`. + #[cfg(any(feature = "std", feature = "alloc"))] pub fn select_columns<'a, I>(&self, icols: I) -> MatrixMN where I: IntoIterator, I::IntoIter: ExactSizeIterator, @@ -296,6 +302,7 @@ impl> Matrix { /// Removes `n` consecutive columns from this matrix, starting with the `i`-th (included). #[inline] + #[cfg(any(feature = "std", feature = "alloc"))] pub fn remove_columns(self, i: usize, n: usize) -> MatrixMN where C: DimSub, @@ -378,6 +385,7 @@ impl> Matrix { /// Removes `n` consecutive rows from this matrix, starting with the `i`-th (included). #[inline] + #[cfg(any(feature = "std", feature = "alloc"))] pub fn remove_rows(self, i: usize, n: usize) -> MatrixMN where R: DimSub, @@ -455,6 +463,7 @@ impl> Matrix { /// Inserts `n` columns filled with `val` starting at the `i-th` position. #[inline] + #[cfg(any(feature = "std", feature = "alloc"))] pub fn insert_columns(self, i: usize, n: usize, val: N) -> MatrixMN where C: DimAdd, @@ -532,6 +541,7 @@ impl> Matrix { /// Inserts `n` rows filled with `val` starting at the `i-th` position. #[inline] + #[cfg(any(feature = "std", feature = "alloc"))] pub fn insert_rows(self, i: usize, n: usize, val: N) -> MatrixMN where R: DimAdd, @@ -697,6 +707,7 @@ impl> Matrix { } } +#[cfg(any(feature = "std", feature = "alloc"))] impl DMatrix { /// Resizes this matrix in-place. /// @@ -704,7 +715,6 @@ impl DMatrix { /// rows and/or columns than `self`, then the extra rows or columns are filled with `val`. /// /// Defined only for owned fully-dynamic matrices, i.e., `DMatrix`. - #[cfg(any(feature = "std", feature = "alloc"))] pub fn resize_mut(&mut self, new_nrows: usize, new_ncols: usize, val: N) where DefaultAllocator: Reallocator { let placeholder = unsafe { Self::new_uninitialized(0, 0) }; @@ -714,6 +724,7 @@ impl DMatrix { } } +#[cfg(any(feature = "std", feature = "alloc"))] impl MatrixMN where DefaultAllocator: Allocator { /// Changes the number of rows of this matrix in-place. @@ -732,6 +743,7 @@ impl MatrixMN } } +#[cfg(any(feature = "std", feature = "alloc"))] impl MatrixMN where DefaultAllocator: Allocator { /// Changes the number of column of this matrix in-place. @@ -830,6 +842,7 @@ unsafe fn extend_rows( /// Extend the number of columns of the `Matrix` with elements from /// a given iterator. +#[cfg(any(feature = "std", feature = "alloc"))] impl Extend for Matrix where N: Scalar, @@ -877,6 +890,7 @@ where /// Extend the number of rows of the `Vector` with elements from /// a given iterator. +#[cfg(any(feature = "std", feature = "alloc"))] impl Extend for Matrix where N: Scalar, @@ -897,6 +911,7 @@ where } } +#[cfg(any(feature = "std", feature = "alloc"))] impl Extend> for Matrix where N: Scalar,