-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
A-lintArea: New lintsArea: New lints
Description
What it does
Applies missing_errors_doc
and missing_panics_doc
to private functions.
This could be done in three ways:
- Add a configuration option on
missing_errors_doc
andmissing_panics_doc
- Add a configuration option on
missing_docs_in_private_items
- Create two new lints
missing_errors_doc_in_private_fn
andmissing_panics_doc_in_private_fn
Advantage
- Documentation is good, especially in large complicated applications
Drawbacks
- Noise if enabled for an existing application
- Can cause useless documentation like
Will error if something goes wrong
Example
/// Does complicated calculation x
fn something_complicated(n: usize) -> Result<usize, String> {
if (n % 2) == 0 {
Ok(n*5)
} else {
Err(format!("{n} is not divisible by 2!"))
}
}
Could be written as:
/// Does complicated calculation x
///
/// # Errors
/// Will error if n is not divisible by 2
fn something_complicated(n: usize) -> Result<usize, String> {
if (n % 2) == 0 {
Ok(n*5)
} else {
Err(format!("{n} is not divisible by 2!"))
}
}
Metadata
Metadata
Assignees
Labels
A-lintArea: New lintsArea: New lints