Expand note about arrays and slices.

This commit is contained in:
Brian Smith 2016-02-22 10:20:01 -10:00
parent a30533becf
commit 981b355617

View File

@ -22,12 +22,15 @@ Use the early-return-on-failure pattern by wrapping calls to functions that may
fail with `try!()`. Do not use `Result::or_else`, `Result::and`, etc. to chain
together strings of potentially-failing operations.
## Arrays
## Arrays and Slices
When creating a slice from the start of a indexable value, use `x[..n]`, not
`x[0..n]`. Similarly, use `x[n..]`, not `x[n..x.len()]` for creating a slice
from a specific point to the end of the value.
When copying and filling arrays and slices, use the functions in
[ring::polyfill](src/polyfill.rs) when possible.
## Casting (`as`) and Conversions
Avoid using the `as` operator. When using `as` seems necessary, see if there is