upgrade to rust 1.38, fix new clippy errors

This commit is contained in:
Dustin Carlino 2019-09-26 14:38:50 -07:00
parent 0961475abc
commit 2554b08641
6 changed files with 30 additions and 28 deletions

View File

@ -23,7 +23,7 @@ To build, you need a Linux-like environment with `bash`, `wget`, `unzip`, etc.
You also `osmosis` for the import script. At runtime if you want to use the
screen-capture plugin, you need `scrot`.
1. Install Rust, at least 1.37. https://www.rust-lang.org/tools/install
1. Install Rust, at least 1.38. https://www.rust-lang.org/tools/install
2. Download the repository:
`git clone https://github.com/dabreegster/abstreet.git`

View File

@ -334,8 +334,8 @@ impl DiffOneTrip {
.sim
.get_canonical_pt_per_trip(trip, &secondary.map)
.ok();
let line = if pt1.is_some() && pt2.is_some() {
Line::maybe_new(pt1.unwrap(), pt2.unwrap())
let line = if let (Some(pt1), Some(pt2)) = (pt1, pt2) {
Line::maybe_new(pt1, pt2)
} else {
None
};

View File

@ -258,16 +258,22 @@ impl GUI for UI {
}
} else if ctx.input.key_pressed(Key::F, "save map fixes") {
self.model.save_fixes();
} else if cursor.is_some() && ctx.input.key_pressed(Key::I, "create intersection") {
self.model.create_i(cursor.unwrap(), ctx.prerender);
self.model.handle_mouseover(ctx);
} else if ctx.input.key_pressed(Key::I, "create intersection") {
if let Some(pt) = cursor {
self.model.create_i(pt, ctx.prerender);
self.model.handle_mouseover(ctx);
}
// TODO Silly bug: Mouseover doesn't actually work! I think the cursor being
// dead-center messes up the precomputed triangles.
} else if cursor.is_some() && ctx.input.key_pressed(Key::B, "create building") {
self.model.create_b(cursor.unwrap(), ctx.prerender);
self.model.handle_mouseover(ctx);
} else if cursor.is_some() && ctx.input.key_pressed(Key::LeftShift, "select area") {
self.state = State::SelectingRectangle(cursor.unwrap(), cursor.unwrap(), true);
} else if ctx.input.key_pressed(Key::B, "create building") {
if let Some(pt) = cursor {
self.model.create_b(pt, ctx.prerender);
self.model.handle_mouseover(ctx);
}
} else if ctx.input.key_pressed(Key::LeftShift, "select area") {
if let Some(pt) = cursor {
self.state = State::SelectingRectangle(pt, pt, true);
}
} else if self.model.showing_pts.is_some()
&& ctx.input.key_pressed(Key::P, "stop moving road points")
{

View File

@ -322,7 +322,7 @@ fn deadend(
let (id, _, pl_a, pl_b) = &lines[0];
let pt1 = pl_a.reversed().safe_dist_along(len).map(|(pt, _)| pt);
let pt2 = pl_b.reversed().safe_dist_along(len).map(|(pt, _)| pt);
if pt1.is_some() && pt2.is_some() {
if let (Some(pt1), Some(pt2)) = (pt1, pt2) {
let r = roads.get_mut(&id).unwrap();
if r.src_i == i {
r.trimmed_center_pts = r
@ -335,12 +335,7 @@ fn deadend(
}
(
close_off_polygon(vec![
pt1.unwrap(),
pt2.unwrap(),
pl_b.last_pt(),
pl_a.last_pt(),
]),
close_off_polygon(vec![pt1, pt2, pl_b.last_pt(), pl_a.last_pt()]),
Vec::new(),
)
} else {

View File

@ -1,7 +1,7 @@
use crate::{osm, LaneType};
use serde_derive::{Deserialize, Serialize};
use std::collections::BTreeMap;
use std::iter;
use std::{fmt, iter};
// (original direction, reversed direction)
pub fn get_lane_types(osm_tags: &BTreeMap<String, String>) -> (Vec<LaneType>, Vec<LaneType>) {
@ -140,19 +140,20 @@ pub struct RoadSpec {
pub back: Vec<LaneType>,
}
impl RoadSpec {
pub fn to_string(&self) -> String {
let mut s: Vec<char> = Vec::new();
impl fmt::Display for RoadSpec {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
for lt in &self.fwd {
s.push(RoadSpec::lt_to_char(*lt));
write!(f, "{}", RoadSpec::lt_to_char(*lt))?;
}
s.push('/');
write!(f, "/")?;
for lt in &self.back {
s.push(RoadSpec::lt_to_char(*lt));
write!(f, "{}", RoadSpec::lt_to_char(*lt))?;
}
s.into_iter().collect()
Ok(())
}
}
impl RoadSpec {
pub fn parse(s: String) -> Option<RoadSpec> {
let mut fwd: Vec<LaneType> = Vec::new();
let mut back: Vec<LaneType> = Vec::new();

View File

@ -146,11 +146,11 @@ impl SidewalkPathfinder {
let back_t = map.get_turn_between(lane1.id, l2, lane1.src_i);
// TODO If both are available, we sort of need to lookahead to pick the better one.
// Oh well.
if fwd_t.is_some() {
if let Some(t) = fwd_t {
if current_i != Some(lane1.dst_i) {
steps.push(PathStep::Lane(lane1.id));
}
steps.push(PathStep::Turn(fwd_t.unwrap()));
steps.push(PathStep::Turn(t));
current_i = Some(lane1.dst_i);
} else {
if current_i != Some(lane1.src_i) {