Skip to content

Commit

Permalink
feat: always have no_std and import std when std feature is activ…
Browse files Browse the repository at this point in the history
…ated
  • Loading branch information
GrayJack committed Jan 19, 2025
1 parent 0ee2e90 commit 5ec9191
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
{
"rust-analyzer.cargo.extraEnv": {
"CFLAGS": "",
"CXXFLAGS": ""
},
"rust-analyzer.checkOnSave.features": ["amalgation", "nightly"],
"rust-analyzer.cargo.features": [
"amalgation", "nightly"
],
"rust-analyzer.imports.preferNoStd": true,
"rust-analyzer.completion.snippets.custom": {
"JanetRS Test": {
"prefix": ["janetrstest", "test"],
Expand Down
5 changes: 4 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
//! ### TODO: Lib level
//! - Better docs.
//! - Marshalling mechanism
#![cfg_attr(not(feature = "std"), no_std)]
#![no_std]
#![cfg_attr(feature = "nightly", feature(allocator_api))]
#![cfg_attr(docsrs, feature(doc_cfg))]

Expand All @@ -67,6 +67,9 @@ compile_error!(r#"You can only use either "amalgation" or "system" feature, not
// Janet requires allocation
extern crate alloc;

#[cfg(any(test, feature = "std"))]
extern crate std;

/// This module has a expose the entire Janet C-API structures, constants and functions.
///
/// This module exists in the case of a functionality of the Janet C-API can't be, or is
Expand Down
1 change: 0 additions & 1 deletion src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use core::{
num::ParseIntError,
};

#[cfg(not(feature = "std"))]
use alloc::{
string::{String, ToString},
vec,
Expand Down
1 change: 0 additions & 1 deletion src/types/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use core::{

use alloc::borrow::Cow;

#[cfg(not(feature = "std"))]
use alloc::{string::String, vec::Vec};

#[cfg(feature = "std")]
Expand Down
1 change: 0 additions & 1 deletion src/types/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use core::{

use alloc::borrow::Cow;

#[cfg(not(feature = "std"))]
use alloc::string::String;

#[cfg(feature = "std")]
Expand Down

0 comments on commit 5ec9191

Please sign in to comment.