ワンクリックで
no-std
no_std Guide guidance for Fortress Rollback. Use when Writing no_std code, embedded targets, core vs alloc decisions.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
no_std Guide guidance for Fortress Rollback. Use when Writing no_std code, embedded targets, core vs alloc decisions.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Crate Publishing guidance for Fortress Rollback. Use when Publishing to crates.io, version bumps, release checklist.
Changelog Practices guidance for Fortress Rollback. Use when Writing CHANGELOG entries, deciding what to document.
Design Decision Log Pattern guidance for Fortress Rollback. Use when Architectural decisions, design alternatives, superseding prior choices.
Repository-wide engineering policy and project context for Fortress Rollback. Use when implementing, diagnosing, reviewing, testing, documenting, or releasing changes in this repository.
GitHub Actions Best Practices guidance for Fortress Rollback. Use when Writing GitHub Actions workflows, CI debugging, actionlint, caching.
Workspace Organization guidance for Fortress Rollback. Use when Organizing workspace, splitting crates, module structure decisions.
| name | no-std |
| description | no_std Guide guidance for Fortress Rollback. Use when Writing no_std code, embedded targets, core vs alloc decisions. |
| Layer | Contains | Requires |
|---|---|---|
core | Primitives, Option, Result, Iterator, PhantomData | Nothing |
alloc | Vec, String, Box, Rc, Arc, BTreeMap, format! | Global allocator |
std | fs, net, thread, time, HashMap, Mutex, io | Operating system |
Note: HashMap/HashSet are NOT in alloc (need randomness). Use BTreeMap or hashbrown.
#![cfg_attr(not(feature = "std"), no_std)]
#[cfg(all(not(feature = "std"), feature = "alloc"))]
extern crate alloc;
// src/prelude.rs
pub use core::cmp::{max, min, Ordering};
pub use core::fmt;
pub use core::mem;
#[cfg(feature = "alloc")]
pub use alloc::{boxed::Box, string::{String, ToString}, vec, vec::Vec};
#[cfg(feature = "std")]
pub use std::collections::{HashMap, HashSet};
#[cfg(all(feature = "alloc", not(feature = "std")))]
pub use hashbrown::{HashMap, HashSet};
[features]
default = ["std"]
std = ["alloc", "dep:parking_lot"]
alloc = []
[dependencies]
# Always: default-features = false
serde = { version = "1", default-features = false, features = ["derive", "alloc"] }
hashbrown = { version = "0.14", optional = true, default-features = false, features = ["alloc"] }
#[cfg(all(feature = "tokio", not(feature = "std")))]
compile_error!("tokio feature requires std");
| std | no_std + alloc | no_std (no heap) |
|---|---|---|
Vec<T> | alloc::vec::Vec<T> | heapless::Vec<T, N> |
String | alloc::string::String | heapless::String<N> |
HashMap | hashbrown::HashMap | heapless::FnvIndexMap |
Box<T> | alloc::boxed::Box<T> | Stack or arena |
Mutex | spin::Mutex | critical-section |
Accept time from outside -- caller is responsible for timing. This enforces determinism.
Use seeded PRNG (rand_xoshiro::Xoshiro256PlusPlus). Use BTreeMap or hashbrown for deterministic iteration.
// no_std: spin-locks or critical-section
use spin::Mutex;
use alloc::sync::Arc; // Arc is in alloc!
std::error::Error is NOT in core (before Rust 1.81).
impl core::fmt::Display for Error { /* ... */ }
#[cfg(feature = "std")]
impl std::error::Error for Error {}
// Rust 1.81+: core::error::Error exists
#[cfg(feature = "std")]
mod std_networking;
#[cfg(target_arch = "wasm32")]
fn get_timestamp() -> u64 { /* js_sys */ }
#[cfg(all(feature = "alloc", not(feature = "std")))]
use hashbrown::HashMap;
# Verify no_std compilation
cargo check --no-default-features --features alloc
cargo check --no-default-features # bare no_std
cargo check --target wasm32-unknown-unknown --no-default-features --features alloc
Tests always have std available (#[cfg(test)] runs with std).
serde (default-features=false), postcard, rkyv
heapless, arrayvec, smallvec, hashbrown, indexmap
bitflags, bytemuck, byteorder, num-traits, static_assertions
ahash, rustc-hash, fnv, sha2, blake3
rand_core, rand_xoshiro, rand_chacha
embedded-hal, critical-section, portable-atomic, defmt
#![cfg_attr(not(feature = "std"), no_std)] in lib.rsextern crate alloc; when using alloc featurecore::/alloc:: instead of std::hashbrown instead of std::collections::HashMapstd::error::Error impl conditional on featuredefault-features = false for ALL dependencieswasm32-unknown-unknownstd::time, std::thread, std::net in core logic