Prefer
-```rust
+```rust,ignore
fn foo(b: Bar) {
// use b as owned, directly
}
over
-```rust
+```rust,ignore
fn foo(b: &Bar) {
let b = b.clone();
// use b as owned after cloning
Prefer
-```rust
+```rust,ignore
fn foo(b: Bar) -> Bar { ... }
```
over
-```rust
+```rust,ignore
fn foo(b: Box<Bar>) -> Box<Bar> { ... }
```
Prefer
-```rust
+```rust,ignore
fn foo<T: Iterator<i32>>(c: T) { ... }
```
over any of
-```rust
+```rust,ignore
fn foo(c: &[i32]) { ... }
fn foo(c: &Vec<i32>) { ... }
fn foo(c: &SomeOtherCollection<i32>) { ... }
Prefer either of
-```rust
+```rust,ignore
fn foo(b: &Bar) { ... }
fn foo(b: &mut Bar) { ... }
```
over
-```rust
+```rust,ignore
fn foo(b: Bar) { ... }
```
Prefer
-```rust
+```rust,ignore
fn foo() -> (Bar, Bar)
```
over
-```rust
+```rust,ignore
fn foo(output: &mut Bar) -> Bar
```
The primary exception: sometimes a function is meant to modify data
that the caller already owns, for example to re-use a buffer:
-```rust
+```rust,ignore
fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize>
```
For example, prefer
-```rust
+```rust,ignore
enum FooMode {
Mode1,
Mode2,
over
-```rust
+```rust,ignore
fn foo(mode2: bool, mode3: bool) {
assert!(!mode2 || !mode3);
...