From d759db682ca8f291e68978ee903c088c7f93e3c6 Mon Sep 17 00:00:00 2001 From: sebcrozet Date: Thu, 24 May 2018 17:17:34 +0200 Subject: [PATCH] Make the alloc feature actually work. --- Cargo.toml | 1 + src/base/default_allocator.rs | 3 +++ src/base/matrix_alga.rs | 3 +++ src/base/matrix_vec.rs | 3 +++ src/lib.rs | 4 ++++ 5 files changed, 14 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 713910ca..21d58393 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,6 +22,7 @@ arbitrary = [ "quickcheck" ] serde-serialize = [ "serde", "serde_derive", "num-complex/serde" ] abomonation-serialize = [ "abomonation" ] debug = [ ] +alloc = [ ] [dependencies] typenum = "1.10" diff --git a/src/base/default_allocator.rs b/src/base/default_allocator.rs index d8ac1382..04197149 100644 --- a/src/base/default_allocator.rs +++ b/src/base/default_allocator.rs @@ -8,6 +8,9 @@ use std::mem; use std::ops::Mul; use std::ptr; +#[cfg(all(feature = "alloc", not(feature = "std")))] +use alloc::Vec; + use generic_array::ArrayLength; use typenum::Prod; diff --git a/src/base/matrix_alga.rs b/src/base/matrix_alga.rs index 68341366..9c12e227 100644 --- a/src/base/matrix_alga.rs +++ b/src/base/matrix_alga.rs @@ -1,3 +1,6 @@ +#[cfg(all(feature = "alloc", not(feature = "std")))] +use alloc::Vec; + use num::{One, Zero}; use alga::general::{ diff --git a/src/base/matrix_vec.rs b/src/base/matrix_vec.rs index e9f4d799..3667b1ff 100644 --- a/src/base/matrix_vec.rs +++ b/src/base/matrix_vec.rs @@ -1,5 +1,8 @@ use std::ops::Deref; +#[cfg(all(feature = "alloc", not(feature = "std")))] +use alloc::Vec; + use base::allocator::Allocator; use base::default_allocator::DefaultAllocator; use base::dimension::{Dim, DimName, Dynamic, U1}; diff --git a/src/lib.rs b/src/lib.rs index 1fc58a1e..cfa2f039 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -85,6 +85,7 @@ an optimized set of tools for computer graphics and physics. Those features incl #![warn(incoherent_fundamental_impls)] #![doc(html_root_url = "http://nalgebra.org/rustdoc")] #![cfg_attr(not(feature = "std"), no_std)] +#![cfg_attr(all(feature = "alloc", not(feature = "std")), feature(alloc))] #[cfg(feature = "arbitrary")] extern crate quickcheck; @@ -113,6 +114,9 @@ extern crate typenum; extern crate alga; +#[cfg(all(feature = "alloc", not(feature = "std")))] +extern crate alloc; + #[cfg(not(feature = "std"))] extern crate core as std;