Przejdź do treści
Biblioteka skilli
Programowanie · Budowanie i kod

rust-no-std

/rust-no-std

Pomaga pisać crate'y Rust z atrybutem no_std: korzystanie z core i alloc bez std, wybór panic handlerów i testowanie kodu no_std na hoście.

Licencja
Apache-2.0
Ostatnia zmiana repozytorium
28.09.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
2
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 28.09.2026, bez odwołań do wycofanych modeli i API.

Licencja

Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.

Co robi i kiedy

Pomaga pisać crate'y Rust z atrybutem no_std: korzystanie z core i alloc bez std, wybór panic handlerów i testowanie kodu no_std na hoście.

Oryginalny opis (EN)

Use when writing #![no_std] Rust crates, using core and alloc without std, selecting panic handlers, or testing no_std code on the host.

Jak działa

  1. Contract
  2. Inputs
  3. Procedure
  4. Failure and recovery
  5. Output
Sekcje z nagłówków SKILL.md, w oryginale · 45 linii, 581 słów
Podgląd SKILL.md
---
name: rust-no-std
description: 'Use when writing #![no_std] Rust crates, using core and alloc without std, selecting panic handlers, or testing no_std code on the host.'
---

# Rust no_std

## Contract

| Field | Bound contract |
|---|---|
| Trigger | The user writes or debugs `#![no_std]` Rust, splits code between `core`, `alloc`, and `std`, implements a global allocator, selects a panic handler, or tests a `no_std` crate on the host. |
| Authority | Reversible local: writes only local `no_std` crate source, `Cargo.toml` feature gates, and report files; rollback is `git checkout --` or `rm` for new files. No remote mutation. |
| Side effect | Local `lib.rs`, `Cargo.toml`, and test files may change; chat emits guidance. |
| Done | The crate builds for the target, the allocator or panic handler is wired, or the host test runs pass. |

## Inputs

1. The target platform (required): a bare-metal triple, an embedded MCU, or `x86_64-unknown-linux-gnu` for host tests.
2. The task (required): crate structure, `core`/`alloc`/`std` boundaries, global allocator, panic handler, or host testing.
3. Rust version (optional): defaults to 1.98.1 with edition 2024.
4. Allocator crate (optional): for example `linked-list-allocator`, `buddy-alloc`, `dlmalloc`, or `talc`.

## Procedure

1. Identify the target and toolchain. Run `rustc --version` and `rustup target list --installed`. Confirm the target triple is installed. Done when: the target and Rust version are known.
2. Set up the `no_std` crate structure. Add `#![no_std]` at the top of `src/lib.rs`. Gate `alloc` behind a feature with `extern crate alloc` under `#[cfg(feature = "alloc")]`. Keep dependencies `no_std`-compatible. Done when: `cargo check --no-default-features` and `cargo check --all-features` pass.
3. Explain `core` versus `alloc` versus `std`. State that `core` needs no OS or heap, `alloc` needs a global allocator, and `std` needs an OS. List the modules available in `core`. Done when: the user can choose the right crate for each API.
4. Provide a global allocator when `alloc` is enabled. Add the `#[global_allocator]` static, initialize it with the heap start and size, and call the init function before any allocation. Done when: `alloc::vec::Vec` and `alloc::string::String` work on the target.
5. Select a panic handler. Add `#[panic_handler] fn panic(_info: &PanicInfo) -> !`. Choose `loop {}` for a halt, `defmt` plus `cortex_m::asm::udf()` for a debug probe, or a `panic-halt`/`panic-reset`/`panic-probe` crate. Done when: the binary links without a missing panic handler.
6. Write portable `no_std` libraries. Return borrowed data from `core` APIs and put `alloc` APIs behind `#[cfg(feature = "alloc")]`. Use borrowed slices for the core path. Done when: the library builds with and without the `alloc` feature.
7. Test on the host. Use `#![cfg_attr(not(test), no_std)]` to keep `std` available to the test harness, or run `cargo test --target x86_64-unknown-linux-gnu` for logic tests. For bare-metal targets, use `cargo check --target <triple>`. Done when: host tests pass or the target build succeeds.

## Failure and recovery

| Failure class | Behavior |
|---|---|
| `no_std` crate still links `std` | Check dependencies for `std` features and remove or replace them. |
| `alloc` types fail to compile | Confirm `extern crate alloc` and a `#[global_allocator]` are present and initialized. |
| Missing panic handler | Add `#[panic_handler]` or depend on a `panic-*` crate. |
| Host tests pull in `std` code | Use `cfg_attr(not(test), no_std)` and keep tests separate from library `std` use. |
| Bare-metal target has no test runner | Run pure logic tests on the host or use an embedded test harness such as `defmt-test`. |

## Output

1. A `no_std` crate structure with feature-gated `alloc`.
2. A global allocator and panic handler wired for the target.
3. Host test or target build command output and a chat report.
Pliki w paczce (2)
  • SKILL.md 4 KB
  • agents/openai.yaml 1 KB

Wersje

RepozytoriumWynikLicencja
Ta strona · OutlineDriven/outline-driven-development100Apache-2.0
mohitmishra786/low-level-dev-skills100MIT

Migawka bazy z 13.11.2026 · wersja paczki 4208e8dbf7e0 (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 100rs-skill-creator
    Tworzy skille dla crate'ów Rust i dokumentacji std, na przykład skill dla tokio, serde czy axum, z gotowej dokumentacji.
  • 100rust-system-calls
    Podpowiada, jak wykonywać wywołania systemowe i operacje na plikach w Rust przez bun_sys zamiast std::fs lub libc.
  • 100exploring-rust-crates
    Generuje dokumentację Rust, by zrozumieć API, strukturę i użycie crate'ów w workspace HASH.
  • 100effective-rust
    Podpowiada idiomatyczny Rust przy pisaniu, przeglądzie i debugowaniu kodu, z użyciem biblioteki standardowej i sprawdzonych crate'ów.
  • 100rust-programming
    Pomaga pisać, przeglądać i refaktoryzować kod Rust: crate'y w workspace, publiczne API, obsługę błędów, async i ownership.
  • 86rust-review
    Przegląda kod Rust, diff lub crate przed wdrożeniem i ocenia, czy jest poprawny oraz idiomatyczny.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.