| Crates.io | api-guidelines |
| lib.rs | api-guidelines |
| version | 0.1.1 |
| created_at | 2025-11-24 07:57:43.581688+00 |
| updated_at | 2025-11-25 01:53:46.995376+00 |
| description | Rust API guidelines enums and utilities for code quality and best practices |
| homepage | |
| repository | https://github.com/slightmeta/api-guidelines |
| max_upload_size | |
| id | 1947516 |
| size | 102,211 |
A comprehensive Rust library providing structured enums and utilities for the official Rust API Guidelines. This crate helps developers follow Rust best practices by providing programmatic access to API design principles.
This library implements the complete Rust API Guidelines as structured enums, making it easier to:
Add this to your Cargo.toml:
[dependencies]
api-guidelines = "0.1.0"
use api_guidelines::{Naming, Interoperability, Predictability, Flexibility};
fn main() {
// Reference naming conventions
let naming_convention = Naming::C_CASE;
let conversion_guideline = Naming::C_CONV;
// Reference interoperability guidelines
let common_traits = Interoperability::C_COMMON_TRAITS;
let conversion_traits = Interoperability::C_CONV_TRAITS;
// Reference predictability guidelines
let smart_ptr_guideline = Predictability::C_SMART_PTR;
let constructor_guideline = Predictability::C_CTOR;
// Use in documentation or tooling
println!("Following guideline: {:?}", naming_convention);
println!("Following guideline: {:?}", conversion_traits);
println!("Following guideline: {:?}", smart_ptr_guideline);
}
C_CASE - Casing conventions (UpperCamelCase vs snake_case)C_CONV - Conversion method naming (as_, to_, into_)C_GETTER - Getter naming conventionsC_ITER - Iterator method namingC_ITER_TY - Iterator type namingC_FEATURE - Feature naming conventionsC_WORD_ORDER - Consistent word orderC_COMMON_TRAITS - Common trait implementationsC_CONV_TRAITS - Standard conversion traitsC_COLLECT - FromIterator and Extend implementationsC_SERDE - Serde serialization supportC_SEND_SYNC - Send and Sync implementationsC_GOOD_ERR - Error type best practicesC_NUM_FMT - Number formatting traitsC_RW_VALUE - Reader/Writer function parametersC_SMART_PTR - Smart pointers don't add inherent methodsC_CONV_SPECIFIC - Conversions live on the most specific typeC_METHOD - Functions with clear receivers are methodsC_NO_OUT - Functions don't take out-parametersC_OVERLOAD - Operator overloads are unsurprisingC_DEREF - Only smart pointers implement Deref and DerefMutC_CTOR - Constructors are static, inherent methodsC_INTERMEDIATE - Functions expose intermediate resultsC_CALLER_CONTROL - Caller decides where to copy and place dataC_GENERIC - Functions minimize assumptions using genericsC_OBJECT - Traits are object-safe if useful as trait objectsC_NEWTYPE - Newtypes provide static distinctionsC_CUSTOM_TYPE - Arguments convey meaning through typesC_BITFLAG - Types for flags are bitflags, not enumsC_BUILDER - Builders enable construction of complex valuesC_VALIDATE - Functions validate their argumentsC_DTOR_FAIL - Destructors never failC_DTOR_BLOCK - Destructors that may block have alternativesC_DEBUG - All public types implement DebugC_DEBUG_NONEMPTY - Debug representation is never emptyC_SEALED - Sealed traits protect against downstream implementationsC_STRUCT_PRIVATE - Structs have private fieldsC_NEWTYPE_HIDE - Newtypes encapsulate implementation detailsC_STRUCT_BOUNDS - Data structures don't duplicate derived trait boundsC_STABLE - Public dependencies of stable crates are stableC_PERMISSIVE - Crate and dependencies have permissive licenseC_CRATE_DOC - Crate level docs are thorough with examplesC_EXAMPLE - All items have rustdoc examplesC_QUESTION_MARK - Examples use ?, not try!, not unwrapC_FAILURE - Function docs include error, panic, and safety considerationsC_LINK - Prose contains hyperlinks to relevant thingsC_METADATA - Cargo.toml includes all common metadataC_RELNOTES - Release notes document all significant changesC_HIDDEN - Rustdoc doesn't show unhelpful implementation detailsC_EVOCATIVE - Input syntax is evocative of the outputC_MACRO_ATTR - Item macros compose well with attributesC_ANYWHERE - Item macros work anywhere items are allowedC_MACRO_VIS - Item macros support visibility specifiersC_MACRO_TY - Type fragments are flexibleFull documentation is available at docs.rs/api-guidelines.
Contributions are welcome! Please feel free to submit pull requests or open issues.
This project is licensed under the MIT License - see the LICENSE file for details.