|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with |
| 4 | +code in this repository. |
| 5 | + |
| 6 | +## Commands |
| 7 | + |
| 8 | +Build and test: |
| 9 | +```bash |
| 10 | +cargo build |
| 11 | +cargo test --features serde |
| 12 | +cargo test --no-default-features --features heapless,serde |
| 13 | +``` |
| 14 | + |
| 15 | +Linting and formatting: |
| 16 | +```bash |
| 17 | +cargo +nightly fmt |
| 18 | +cargo clippy |
| 19 | +cargo doc --all-features |
| 20 | +``` |
| 21 | + |
| 22 | +## Architecture |
| 23 | + |
| 24 | +This crate provides abstractions over `alloc` and `heapless` collections, |
| 25 | +allowing code to work with both heap-allocated and stack-allocated data |
| 26 | +structures through a unified API. |
| 27 | + |
| 28 | +### Key Design Patterns |
| 29 | + |
| 30 | +- **Feature-based compilation**: Either `alloc` (default) or `heapless` feature |
| 31 | + must be enabled, but not both simultaneously |
| 32 | +- **Capacity parameterization**: All types use const generic `N` parameter for |
| 33 | + capacity control - initial capacity for `alloc`, maximum capacity for |
| 34 | + `heapless` |
| 35 | +- **Fallible operations**: Methods return `Result<T, Error>` to handle capacity |
| 36 | + limits in `heapless` mode, though they're infallible with `alloc` |
| 37 | +- **Backend abstraction**: Internal `Inner<T, N>` type aliases provide |
| 38 | + conditional compilation between `alloc::vec::Vec<T>` and `heapless::Vec<T, N>` |
| 39 | + |
| 40 | +### Core Modules |
| 41 | + |
| 42 | +- `vec.rs`: Vec implementation with unified API over both backends |
| 43 | +- `string.rs`: String implementation with unified API over both backends |
| 44 | +- `error.rs`: Error types (`BufferOverflow`, `Utf8Error`) and Result alias |
| 45 | +- `lib.rs`: Feature gates, re-exports, and serde integration tests |
| 46 | + |
| 47 | +The crate uses `#![no_std]` and requires explicit `extern crate alloc` when |
| 48 | +alloc feature is enabled. |
0 commit comments