Skip to content

Commit

Permalink
Merge rust-lang#36
Browse files Browse the repository at this point in the history
36: Add `#![no_std]` support r=matklad a=ark0f



Co-authored-by: Arsenii Lyashenko <arsenylyashenko.3@gmail.com>
  • Loading branch information
bors[bot] and ark0f authored Aug 12, 2021
2 parents cd87249 + c306ed3 commit a9b5875
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .github/ci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ fn try_main() -> Result<()> {
cwd.display()
);

{
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")?;
Expand Down
6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ authors = ["Aleksey Kladov <aleksey.kladov@gmail.com>"]
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"]
16 changes: 16 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -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>()`
Expand Down

0 comments on commit a9b5875

Please sign in to comment.