Add the std / no_std feature.
This commit is contained in:
parent
a24826b879
commit
393a8c2f15
@ -19,3 +19,6 @@ script:
|
||||
- echo "Testing feature serialization"
|
||||
- cargo build --verbose --features serialization
|
||||
- cargo test --verbose --features serialization
|
||||
- echo "Testing without std"
|
||||
- cargo build --verbose --no-default-features
|
||||
- cargo test --verbose --no-default-features
|
||||
|
@ -18,8 +18,9 @@ is-it-maintained-open-issues = { repository = "phaazon/splines" }
|
||||
maintenance = { status = "actively-developed" }
|
||||
|
||||
[features]
|
||||
default = []
|
||||
default = ["std"]
|
||||
serialization = ["serde", "serde_derive"]
|
||||
std = []
|
||||
|
||||
[dependencies]
|
||||
cgmath = "0.16"
|
||||
|
@ -9,6 +9,11 @@ Feel free to dig in the [online documentation](https://docs.rs/splines) for furt
|
||||
|
||||
This crate has features! Here’s a comprehensive list of what you can enable:
|
||||
|
||||
- **Serialization / deserialization**
|
||||
- **Serialization / deserialization.**
|
||||
+ This feature implements both the `Serialize` and `Deserialize` traits from `serde`.
|
||||
+ Enable with the feature `"serialization"`.
|
||||
+ Enable with the `"serialization"` feature.
|
||||
- **Standard library / no stdandard library**
|
||||
+ It’s possible to compile against the standard library or go on your own without it.
|
||||
+ Compiling with the standard library is enabled by default.
|
||||
+ Use `defaut-features = []` in your `Cargo.toml` to disable.
|
||||
+ Enable explicitly with the `"std"` feataure.
|
||||
|
27
src/lib.rs
27
src/lib.rs
@ -76,9 +76,20 @@
|
||||
//!
|
||||
//! So here’s a list of currently supported features and how to enable them:
|
||||
//!
|
||||
//! - **Serialization / deserialization**
|
||||
//! - **Serialization / deserialization.**
|
||||
//! + This feature implements both the `Serialize` and `Deserialize` traits from `serde`.
|
||||
//! + Enable with the feature `"serialization"`.
|
||||
//! + Enable with the `"serialization"` feature.
|
||||
//! - **Standard library / no stdandard library**
|
||||
//! + It’s possible to compile against the standard library or go on your own without it.
|
||||
//! + Compiling with the standard library is enabled by default.
|
||||
//! + Use `defaut-features = []` in your `Cargo.toml` to disable.
|
||||
//! + Enable explicitly with the `"std"` feataure.
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
#![cfg_attr(not(feature = "std"), feature(alloc))]
|
||||
|
||||
// on no_std, we also need the alloc crate for Vec
|
||||
#[cfg(not(feature = "std"))] extern crate alloc;
|
||||
|
||||
extern crate cgmath;
|
||||
|
||||
@ -86,9 +97,15 @@ extern crate cgmath;
|
||||
#[cfg(feature = "serialization")] #[macro_use] extern crate serde_derive;
|
||||
|
||||
use cgmath::{InnerSpace, Quaternion, Vector2, Vector3, Vector4};
|
||||
use std::cmp::Ordering;
|
||||
use std::f32::consts;
|
||||
use std::ops::{Add, Div, Mul, Sub};
|
||||
|
||||
#[cfg(feature = "std")] use std::cmp::Ordering;
|
||||
#[cfg(feature = "std")] use std::f32::consts;
|
||||
#[cfg(feature = "std")] use std::ops::{Add, Div, Mul, Sub};
|
||||
|
||||
#[cfg(not(feature = "std"))] use alloc::vec::Vec;
|
||||
#[cfg(not(feature = "std"))] use core::cmp::Ordering;
|
||||
#[cfg(not(feature = "std"))] use core::f32::consts;
|
||||
#[cfg(not(feature = "std"))] use core::ops::{Add, Div, Mul, Sub};
|
||||
|
||||
/// A spline control point.
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user