Add advice about imports and name qualification to STYLE.md.
This commit is contained in:
parent
3ba9481cc2
commit
da41b3b27e
9
STYLE.md
9
STYLE.md
@ -7,6 +7,15 @@ style guidelines for that code are in the second section of this document.
|
|||||||
*ring* usually follows the [Rust Guidelines](https://aturon.github.io/), but
|
*ring* usually follows the [Rust Guidelines](https://aturon.github.io/), but
|
||||||
there are some differences and *ring* adds additional guidelines.
|
there are some differences and *ring* adds additional guidelines.
|
||||||
|
|
||||||
|
## Imports (`use`) and Qualification
|
||||||
|
|
||||||
|
In general, import modules, not non-module items, e.g. `use core`, not
|
||||||
|
`use core::mem::size_of_val`. This means that the uses of such functions must
|
||||||
|
be qualified: `core::mem::size_of_val(x)`, not `size_fo_val(x)`. Exceptions may
|
||||||
|
be made for things that are very annoying to qualify; for example, we usually
|
||||||
|
`use super::input::*` or `use super::input::Input` because writing things like
|
||||||
|
`input::Input` is highly annoying.
|
||||||
|
|
||||||
## Error checking
|
## Error checking
|
||||||
|
|
||||||
Use `Result<T, ()>` as the return type for functions that may fail. Never use
|
Use `Result<T, ()>` as the return type for functions that may fail. Never use
|
||||||
|
Loading…
x
Reference in New Issue
Block a user