Thank you for your interest in contributing to rust-sort! This document provides guidelines for contributing to make the process smooth and effective for everyone involved.
We are committed to providing a welcoming and inclusive experience for all. Please be respectful and professional in all interactions.
- Fork the repository on GitHub
- Clone your fork locally:
git clone https://github.com/your-username/rust-sort.git cd rust-sort - Create a new branch for your feature:
git checkout -b feature/your-feature-name
- Install development dependencies:
rustup update cargo install cargo-clippy cargo-fmt
# Ensure you have the latest stable Rust
rustup update stable
# Install development tools
rustup component add clippy rustfmt
# Run tests to verify setup
cargo test- Check existing issues - see if your idea is already being discussed
- Create an issue for major changes to discuss the approach
- Read the code - understand the existing architecture and patterns
- Write tests first - we practice test-driven development
- Follow the coding style - use
cargo fmtandcargo clippy - Add documentation - update docs for any public API changes
- Test performance - run benchmarks for performance-sensitive changes
// ✅ Good: Clear, documented function
/// Sorts the input using adaptive algorithm selection
///
/// # Arguments
/// * `data` - The data to sort
/// * `config` - Sorting configuration
///
/// # Returns
/// * `Result<(), SortError>` - Success or error details
pub fn adaptive_sort(data: &mut [String], config: &SortConfig) -> SortResult<()> {
// Implementation
}
// ❌ Bad: Undocumented, unclear function
pub fn sort_stuff(x: &mut [String], y: &SortConfig) -> Result<(), Box<dyn Error>> {
// Implementation
}- Benchmark critical paths - use
cargo benchfor performance-sensitive code - Profile memory usage - avoid unnecessary allocations
- Consider SIMD opportunities - vectorize when possible
- Minimize system calls - batch I/O operations
// ✅ Good: Specific error types
use thiserror::Error;
#[derive(Error, Debug)]
pub enum SortError {
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("Invalid configuration: {message}")]
InvalidConfig { message: String },
}
// ❌ Bad: Generic error handling
fn some_function() -> Result<(), Box<dyn Error>> {
// Don't use generic error types
}# Run all tests
cargo test
# Run specific test module
cargo test core_sort
# Run tests with output
cargo test -- --nocapture# Run benchmarks to verify correctness and performance
./benchmark.sh
# Run with large datasets (requires disk space)
./benchmark.sh --large# Run micro-benchmarks
cargo bench
# Profile performance
cargo build --release
perf record target/release/sort large_file.txt
perf report- Update README.md for user-facing changes
- Add doc comments for all public APIs
- Include examples in documentation
- Update CHANGELOG.md for notable changes
When reporting bugs, please include:
**Describe the bug**
A clear description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Command used: `sort -n file.txt`
2. Input data: `[attach or describe]`
3. Expected output: `[what you expected]`
4. Actual output: `[what actually happened]`
**Environment**
- OS: [e.g., Ubuntu 20.04, macOS 12.0]
- Rust version: `rustc --version`
- rust-sort version: `sort --version`
**Additional context**
Any other information about the problem.For new features:
- Search existing issues first
- Describe the use case - why is this feature needed?
- Propose the interface - how should it work?
- Consider compatibility - how does it fit with GNU sort?
- Bug fixes
- Documentation improvements
- Minor performance optimizations
These can be submitted directly as pull requests.
- New sorting algorithms
- Architectural changes
- Breaking API changes
Please create an issue first to discuss the approach.
Look for issues labeled good first issue:
- Documentation improvements
- Adding test cases
- Small bug fixes
- Code cleanup tasks
-
Run the full test suite:
cargo test cargo clippy -- -D warnings cargo fmt --check ./benchmark.sh -
Update documentation if needed
-
Add changelog entry for user-facing changes
## Description
Brief description of changes made.
## Type of Change
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Documentation update
## Testing
- [ ] Unit tests pass: `cargo test`
- [ ] Linting passes: `cargo clippy`
- [ ] Formatting is correct: `cargo fmt`
- [ ] Benchmarks pass: `./benchmark.sh`
- [ ] Added tests for new functionality
## Performance Impact
- [ ] No performance impact expected
- [ ] Performance improvement (include benchmark results)
- [ ] Potential performance regression (justified by other benefits)
## Checklist
- [ ] My code follows the project's style guidelines
- [ ] I have performed a self-review of my code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes- Automated checks run on all PRs (CI, tests, formatting)
- Maintainer review - we aim to review within 2-3 days
- Address feedback - respond to review comments
- Final approval - maintainer will merge when ready
When contributing performance improvements:
-
Benchmark before and after:
# Before changes ./benchmark.sh > before.txt # After changes ./benchmark.sh > after.txt # Compare results diff before.txt after.txt
-
Profile bottlenecks:
cargo build --release perf record -g target/release/sort large_file.txt perf report
-
Consider memory usage:
valgrind --tool=massif target/release/sort large_file.txt
For new sorting algorithms:
- Research existing literature - cite papers or references
- Implement with clear documentation - explain the algorithm
- Add comprehensive tests - edge cases and correctness
- Benchmark against existing algorithms - show when it's beneficial
- Consider adaptive integration - when should this algorithm be used?
For vectorized code:
- Use platform-agnostic code when possible
- Provide fallbacks for unsupported architectures
- Test on multiple platforms if possible
- Document SIMD requirements clearly
type(scope): description
[optional body]
[optional footer]
feat: New featurefix: Bug fixdocs: Documentation only changesstyle: Code style changes (formatting, etc.)refactor: Code refactoringperf: Performance improvementstest: Adding or updating testschore: Maintenance tasks
feat(radix): add radix sort implementation for integers
fix(simd): handle unaligned memory access correctly
docs(readme): update performance comparison table
perf(core): optimize string comparison with SIMDContributors are recognized in:
- README.md - major contributors listed
- CHANGELOG.md - contributions noted in releases
- GitHub contributors page - automatic recognition
- GitHub Issues - for bugs and feature requests
- GitHub Discussions - for questions and ideas
- Discord - real-time chat (link in README)
- The Rust Programming Language
- Rust by Example
- The Rustonomicon - for unsafe code
- Introduction to Algorithms by Cormen, Leiserson, Rivest, and Stein
- Sorting Algorithm Visualizations
Thank you for contributing to rust-sort! Your efforts help make this tool better for everyone. 🙏