Unnamed repository; edit this file 'description' to name the repository.
| -rw-r--r-- | lib/smol_str/.github/ci.rs | 5 | ||||
| -rw-r--r-- | lib/smol_str/Cargo.toml | 6 | ||||
| -rw-r--r-- | lib/smol_str/src/lib.rs | 16 |
3 files changed, 26 insertions, 1 deletions
diff --git a/lib/smol_str/.github/ci.rs b/lib/smol_str/.github/ci.rs index b293ebbcb7..98017ad97f 100644 --- a/lib/smol_str/.github/ci.rs +++ b/lib/smol_str/.github/ci.rs @@ -24,6 +24,11 @@ fn try_main() -> Result<()> { ); { + let _s = Section::new("BUILD_NO_DEFAULT_FEATURES"); + shell("cargo test --all-features --workspace --no-run --no-default-features")?; + } + + { let _s = Section::new("BUILD"); shell("cargo test --all-features --workspace --no-run")?; } diff --git a/lib/smol_str/Cargo.toml b/lib/smol_str/Cargo.toml index fe2497cfd6..f9c3a350f2 100644 --- a/lib/smol_str/Cargo.toml +++ b/lib/smol_str/Cargo.toml @@ -8,10 +8,14 @@ authors = ["Aleksey Kladov <[email protected]>"] edition = "2018" [dependencies] -serde = { version = "1", optional = true, default_features = false, features = [ "std" ] } +serde = { version = "1", optional = true, default_features = false } arbitrary = { version = "1", optional = true } [dev-dependencies] proptest = "0.10" serde_json = "1" serde = { version = "1", features = [ "derive" ] } + +[features] +default = ["std"] +std = ["serde/std"] diff --git a/lib/smol_str/src/lib.rs b/lib/smol_str/src/lib.rs index 1583dfe077..9f99153f2a 100644 --- a/lib/smol_str/src/lib.rs +++ b/lib/smol_str/src/lib.rs @@ -1,11 +1,27 @@ +#![cfg_attr(not(feature = "std"), no_std)] + +#[cfg(not(feature = "std"))] +extern crate core as std; + +#[cfg(not(feature = "std"))] +extern crate alloc; + use std::{ borrow::Borrow, cmp::{self, Ordering}, fmt, hash, iter, ops::Deref, +}; + +#[cfg(not(feature = "std"))] +use alloc::{ + string::{String, ToString}, sync::Arc, }; +#[cfg(feature = "std")] +use std::sync::Arc; + /// A `SmolStr` is a string type that has the following properties: /// /// * `size_of::<SmolStr>() == size_of::<String>()` |