원클릭으로
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