Instruction file imported from sethdford/Just-Call-Me-Al (
.cursor/rules/utilities.mdc). Copyright stays with the author.
Utility Code Guidelines
-
Location
- Place general-purpose utility functions and types in a dedicated
src/utilsmodule or similar. - Group related utilities into submodules (e.g.,
src/utils/tensor.rs,src/utils/time.rs).
- Place general-purpose utility functions and types in a dedicated
-
Scope
- Utilities should be genuinely reusable across different parts of the application.
- Avoid placing domain-specific logic in the
utilsmodule; it should belong in the relevant domain module (e.g.,src/audio,src/models).
-
Simplicity and Purity
- Utility functions should ideally be small, focused, and pure (no side effects) where possible.
- Make dependencies explicit through function arguments rather than relying on global state.
-
Documentation
- Document all public utility functions and types clearly, explaining their purpose and usage.
- Include examples in doctests.
-
Testing
- Write unit tests for all utility functions, covering various inputs and edge cases.
-
Naming
- Use clear and descriptive names that indicate the utility's function.