diff --git a/Cargo.toml b/Cargo.toml index 1caec25f..71f72384 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -111,4 +111,4 @@ lto = true [package.metadata.docs.rs] # Enable certain features when building docs for docs.rs -features = [ "proptest-support", "compare" ] +features = [ "proptest-support", "compare", "macros" ] diff --git a/nalgebra-macros/src/lib.rs b/nalgebra-macros/src/lib.rs index 133ea41a..c00a538f 100644 --- a/nalgebra-macros/src/lib.rs +++ b/nalgebra-macros/src/lib.rs @@ -1,3 +1,8 @@ +//! Macros for `nalgebra`. +//! +//! This crate is not intended for direct consumption. Instead, the macros are re-exported by +//! `nalgebra` if the `macros` feature is enabled (enabled by default). + extern crate proc_macro; use syn::{Expr}; @@ -95,6 +100,8 @@ impl Parse for Matrix { /// Construct a fixed-size matrix directly from data. /// +/// **Note: Requires the `macro` feature to be enabled (enabled by default)**. +/// /// This macro facilitates easy construction of matrices when the entries of the matrix are known /// (either as constants or expressions). This macro produces an instance of `SMatrix`. This means /// that the data of the matrix is stored on the stack, and its dimensions are fixed at @@ -146,6 +153,8 @@ pub fn matrix(stream: TokenStream) -> TokenStream { /// Construct a dynamic matrix directly from data. /// +/// **Note: Requires the `macro` feature to be enabled (enabled by default)**. +/// /// The syntax is exactly the same as for [`matrix!`], but instead of producing instances of /// `SMatrix`, it produces instances of `DMatrix`. At the moment it is not usable /// in `const fn` contexts. @@ -213,6 +222,8 @@ impl Parse for Vector { /// Construct a fixed-size column vector directly from data. /// +/// **Note: Requires the `macro` feature to be enabled (enabled by default)**. +/// /// Similarly to [`matrix!`], this macro facilitates easy construction of fixed-size vectors. /// However, whereas the [`matrix!`] macro expects each row to be separated by a semi-colon, /// the syntax of this macro is instead similar to `vec!`, in that the elements of the vector @@ -243,6 +254,8 @@ pub fn vector(stream: TokenStream) -> TokenStream { /// Construct a dynamic column vector directly from data. /// +/// **Note: Requires the `macro` feature to be enabled (enabled by default)**. +/// /// The syntax is exactly the same as for [`vector!`], but instead of producing instances of /// `SVector`, it produces instances of `DVector`. At the moment it is not usable /// in `const fn` contexts. diff --git a/tests/lib.rs b/tests/lib.rs index 8ee85f07..b1da01c3 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -1,7 +1,7 @@ -#[cfg(not(all(feature = "debug", feature = "compare", feature = "rand")))] +#[cfg(not(all(feature = "debug", feature = "compare", feature = "rand", feature = "macros")))] compile_error!( - "Please enable the `debug`, `compare`, and `rand` features in order to compile and run the tests. - Example: `cargo test --features debug,compare,rand`" + "Please enable the `debug`, `compare`, `rand` and `macros` features in order to compile and run the tests. + Example: `cargo test --features debug,compare,rand,macros`" ); #[cfg(feature = "abomonation-serialize")] @@ -25,6 +25,8 @@ mod linalg; #[cfg(feature = "proptest-support")] mod proptest; +mod macros; + //#[cfg(all(feature = "debug", feature = "compare", feature = "rand"))] //#[cfg(feature = "sparse")] //mod sparse;