Keep modules focused and well-organized by grouping related functionality together and splitting large files into logical submodules. Each file should have a clear, single responsibility. When a file grows too large or handles multiple concerns, consider breaking it into smaller, more focused modules.
Keep modules focused and well-organized by grouping related functionality together and splitting large files into logical submodules. Each file should have a clear, single responsibility. When a file grows too large or handles multiple concerns, consider breaking it into smaller, more focused modules.
For example, instead of:
// types.rs (large file with mixed concerns)
pub(crate) trait VarianceInferable<'db>: Sized {
// ... variance-related code
}
pub(crate) struct TypeVarInstance<'db> {
// ... type variable code
}
Prefer:
// types/variance.rs
pub(crate) trait VarianceInferable<'db>: Sized {
// ... variance-related code
}
// types/type_var.rs
pub(crate) struct TypeVarInstance<'db> {
// ... type variable code
}
Key guidelines:
Enter the URL of a public GitHub repository