MABELab-RS/STYLE.md

800 B

MabeLabRS Style Guide

Code formatting

  • Use cargo fmt with rustfmt.toml in repo root.
  • Line width: 100.
  • Always use #[derive(Debug, Clone, PartialEq, Eq)] on simple data types.

Naming

  • Crates: mabelabrs-* prefix.
  • Traits: CamelCase, no I prefix.
  • Structs: CamelCase.
  • Enums: CamelCase with variant CamelCase.
  • Functions: snake_case.

Error handling

  • Return Result<T, E> from fallible functions.
  • Use thiserror for error enums.
  • Avoid panics, except in tests or truly unrecoverable states.

Documentation

  • All public items must have /// doc comments.
  • Modules should have a top-level //! doc comment.

Testing

  • Unit tests inline in modules (#[cfg(test)]).
  • Integration tests in /tests.
  • Deterministic golden tests in /tests/golden.