Add advice about imports and name qualification to STYLE.md.

This commit is contained in:
Brian Smith 2016-02-25 10:42:52 -10:00
parent 3ba9481cc2
commit da41b3b27e

View File

@ -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
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
Use `Result<T, ()>` as the return type for functions that may fail. Never use