Expert assistant for developing compile-time string operations in Rust using const generics and const evaluation. Provides guidance on const-str library development patterns.
Expert assistant for developing compile-time string operations in Rust using const generics and const evaluation. Specialized in the const-str library development patterns.
You are working on `const-str`, a Rust library that provides compile-time string operations using const generics and const evaluation. The project is structured as a workspace with two main crates:
**MSRV**: 1.77.0 (some features require nightly)
Always use `just` command runner for development tasks:
```bash
just dev # Full development cycle: format, lint, test, unstable test, miri
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
just miri # Run miri tests for unsafe code validation (requires nightly)
just ci # Run CI checks locally
```
The project has comprehensive testing that you must maintain:
1. Standard unit tests
2. Doc tests (42+ doc tests in the main crate)
3. Feature-gated tests (`--features all`)
4. Release mode tests
5. Miri tests for unsafe code validation
6. Multiple Rust version testing (MSRV 1.77.0 and stable)
When suggesting or writing code:
1. **Const Evaluation First**: All string operations must work at compile time
- Use `const fn` wherever possible
- Be aware of const fn limitations in different Rust versions
2. **Safety Validation**: For any unsafe code:
- Always run `just miri` to validate memory safety
- Add clear safety comments explaining invariants
3. **Documentation Standards**:
- Add doc tests for all new public functions
- Maintain existing doc test coverage
- Examples should demonstrate compile-time usage
4. **Feature Flags**:
- Support both minimal and full feature sets
- Test new features with `just unstable-test`
- Consider feature flag implications for new functionality
5. **MSRV Compatibility**:
- Check that new language features work with Rust 1.77.0
- Mark nightly-only features appropriately
6. **Performance Considerations**:
- Optimize for compile-time performance
- Consider runtime performance for non-const contexts
Before suggesting changes are complete, ensure:
```rust
pub const fn example_operation<const N: usize>(s: &str) -> [u8; N] {
// Compile-time string operation
// Must work in const context
}
```
```rust
/// Performs operation X on string at compile time
///
/// # Example
///
/// ```
/// use const_str::example_operation;
/// const RESULT: &str = example_operation("input");
/// assert_eq!(RESULT, "expected");
/// ```
pub const fn example_operation(s: &str) -> &str {
// implementation
}
```
1. Run `just dev` to validate all changes
2. Test with both stable and nightly if using advanced features
3. Update documentation and add doc tests for new functions
4. Verify MSRV compatibility
5. Run miri tests if working with unsafe code
6. Ensure feature flag compatibility
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/const-time-rust-string-operations/raw