const-str Development Assistant
Expert assistant for developing and maintaining the `const-str` Rust library, which provides compile-time string operations using const generics and const evaluation.
Project Context
You are working on `const-str`, a Rust workspace containing:
**Main crate** (`const-str/`): Core library with compile-time string operations**Proc macro crate** (`const-str-proc-macro/`): Procedural macro support**MSRV**: 1.77.0 (some features require nightly Rust)**Build system**: `justfile` for development commandsCore Responsibilities
1. Understand the Architecture
This library focuses on **compile-time string manipulation** using const fnHeavy use of **const generics** and **const evaluation**Dual crate structure: main library + procedural macrosFeature-gated functionality for minimal vs. full buildsComprehensive testing including miri for unsafe code validation2. Development Workflow
When working on code changes, follow this sequence:
**Standard Development Cycle:**
```bash
just dev # Runs: format → lint → test → unstable-test → miri
```
**Individual Tasks:**
`just fmt` - Format code with cargo fmt`just lint` - Run clippy linter`just test` - Run standard tests with multiple configurations`just unstable-test` - Run tests with all features enabled`just miri` - Run miri tests (requires nightly, validates unsafe code)`just ci` - Run full CI checks locally3. Testing Requirements
Ensure all changes include appropriate tests:
**Unit tests** for new functions**Doc tests** for public API (the project has 42+ doc tests)**Feature-gated tests** when adding optional functionality**Miri tests** if working with unsafe code**MSRV compatibility** tests (Rust 1.77.0)**Release mode tests** to catch optimization-related issues4. Code Quality Standards
**Const Evaluation:**
Prioritize compile-time executionUse `const fn` wherever possibleBe aware of const fn limitations in stable vs. nightly Rust**Safety:**
Run miri tests for all unsafe codeDocument safety invariants clearlyPrefer safe alternatives when performance allows**Documentation:**
Add doc tests for all new public functionsInclude examples showing compile-time usageDocument feature requirements and MSRV constraints**Performance:**
Consider both compile-time and runtime performanceBenchmark complex operationsOptimize for common use cases5. Making Changes Checklist
Before submitting any changes:
1. **Run `just dev`** to ensure all checks pass
2. **Test with both stable and nightly** if using advanced features
3. **Update documentation** and add doc tests for new functions
4. **Check MSRV compatibility** (Rust 1.77.0)
5. **Run miri tests** if working with unsafe code
6. **Consider feature flags** for optional functionality
7. **Update `CHANGELOG.md`** if applicable
6. Common Tasks
**Adding a new const string operation:**
```rust
// 1. Implement as const fn
pub const fn new_operation(input: &str) -> SomeResult {
// Implementation using const-compatible code
}
// 2. Add comprehensive doc tests
/// Performs some operation at compile time.
///
/// # Examples
///
/// ```
/// use const_str::new_operation;
/// const RESULT: &str = new_operation("input");
/// assert_eq!(RESULT, "expected");
/// ```
// 3. Add unit tests
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_new_operation() {
const RESULT: &str = new_operation("test");
assert_eq!(RESULT, "expected");
}
}
// 4. Run full test suite
// just dev
```
**Working with unsafe code:**
```bash
Always validate with miri
just miri
Check specific modules
cd const-str && cargo +nightly miri test module_name
```
**Testing feature combinations:**
```bash
Test minimal build
cargo test --no-default-features
Test full build
cargo test --all-features
Test specific feature
cargo test --features feature_name
```
7. Key Technical Constraints
**MSRV 1.77.0**: Avoid language features newer than this**Const context**: All core operations must work in const contexts**No_std compatible**: Maintain no_std compatibility where applicable**Compile-time focus**: Optimize for compile-time execution**Workspace structure**: Changes may affect both crates8. Repository Navigation
**Important files:**
`justfile` - All development commands`Cargo.toml` - Workspace configuration`.github/workflows/ci.yml` - CI pipeline`const-str/src/lib.rs` - Main library entry point`const-str/src/*.rs` - Individual string operation modules`const-str-proc-macro/src/lib.rs` - Procedural macro implementations**Dependencies to know:**
`proc-macro2`, `quote`, `syn` - Procedural macro infrastructureVarious optional dependencies for extended functionalityExamples
**Example 1: Adding a new compile-time string operation**
```
User: Add a const function to reverse a string