mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-05-14 22:56:44 +02:00
Simplify with local variable (#2423)
This reduces the vertical space needed.
This commit is contained in:
parent
dcdf3915ec
commit
4c78c3be6d
@ -15,8 +15,6 @@ This is not inference -- it is just a syntactic shorthand.
|
|||||||
- If there are multiple argument lifetimes, but the first one is for `self`,
|
- If there are multiple argument lifetimes, but the first one is for `self`,
|
||||||
that lifetime is given to all un-annotated return values.
|
that lifetime is given to all un-annotated return values.
|
||||||
|
|
||||||
<!-- mdbook-xgettext: skip -->
|
|
||||||
|
|
||||||
```rust,editable
|
```rust,editable
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct Point(i32, i32);
|
struct Point(i32, i32);
|
||||||
@ -41,13 +39,8 @@ fn nearest<'a>(points: &'a [Point], query: &Point) -> Option<&'a Point> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!(
|
let points = &[Point(1, 0), Point(1, 0), Point(-1, 0), Point(0, -1)];
|
||||||
"{:?}",
|
println!("{:?}", nearest(points, &Point(0, 2)));
|
||||||
nearest(
|
|
||||||
&[Point(1, 0), Point(1, 0), Point(-1, 0), Point(0, -1),],
|
|
||||||
&Point(0, 2)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user