Skip to content

Commit

Permalink
editoast: clippy fixes
Browse files Browse the repository at this point in the history
clippy 0.1.73 (03a119b0 2023-08-07)
  • Loading branch information
leovalais committed Aug 8, 2023
1 parent 948156c commit 8f6aec0
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 14 deletions.
4 changes: 1 addition & 3 deletions editoast/src/generated_data/error/catenaries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,7 @@ pub fn check_overlapping(infra_cache: &InfraCache, _: &Graph) -> Vec<InfraError>
let range = (track_range.begin * 100.) as u64..(track_range.end * 100.) as u64;
let track_id = &track_range.track.0;

let range_map = range_maps
.entry(track_id.clone())
.or_insert(Default::default());
let range_map = range_maps.entry(track_id.clone()).or_default();
for (_, overlap) in range_map.overlapping(&range) {
if catenary.get_id() == overlap {
// Avoid reporting overlap with itself
Expand Down
2 changes: 1 addition & 1 deletion editoast/src/generated_data/error/speed_sections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ pub fn check_overlapping(infra_cache: &InfraCache, _: &Graph) -> Vec<InfraError>
if speed_section.speed_limit.is_some() {
let range_map = range_maps
.entry((track_id.clone(), None, direction))
.or_insert(Default::default());
.or_default();
for (_, overlap) in range_map.overlapping(&range) {
if speed_section.get_id() == overlap {
// Avoid reporting overlap with itself
Expand Down
2 changes: 1 addition & 1 deletion editoast/src/models/timetable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ pub async fn get_timetable_train_schedules_with_simulations(
SimulationOutput::belonging_to(&train_schedules).load::<SimulationOutput>(&mut conn)?;
let result = train_schedules
.into_iter()
.zip(simulation_outputs.into_iter())
.zip(simulation_outputs)
.collect();
Ok(result)
})
Expand Down
2 changes: 1 addition & 1 deletion editoast/src/schema/railjson.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ pub mod test {
let result = infra.persist(railjson.clone(), pool).await;

// THEN
assert!(matches!(result, Ok(_)));
assert!(result.is_ok());
let infra = result.unwrap();

let s_railjson = find_railjson(&mut conn, &infra).unwrap();
Expand Down
5 changes: 2 additions & 3 deletions editoast/src/views/infra/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,8 @@ async fn clone(
});
futures.push(Box::pin(model));

let layer_table = object.get_geometry_layer_table();
if layer_table.is_some() {
let layer_table = layer_table.unwrap().to_string();
if let Some(layer_table) = object.get_geometry_layer_table() {
let layer_table = layer_table.to_string();
let db_pool_ref = db_pool.clone();
let layer = block::<_, Result<_>>(move || {
let mut conn = db_pool_ref.get()?;
Expand Down
4 changes: 2 additions & 2 deletions editoast/src/views/pathfinding/catenaries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl Ord for Float {

impl PartialOrd for Float {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.0.partial_cmp(&other.0)
Some(self.cmp(other))
}
}

Expand Down Expand Up @@ -259,7 +259,7 @@ pub mod tests {
#[fixture]
fn simple_mode_map() -> HashMap<String, RangeMap<Float, String>> {
// The mode map associated to the following catenaries
let mut mode_map = vec![
let mut mode_map = [
("track_1", "25kV"),
("track_2", "25kV"),
("track_5", "1.5kV"),
Expand Down
4 changes: 2 additions & 2 deletions editoast/src/views/pathfinding/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ fn make_track_map<I: Iterator<Item = String>>(
{
Ok(ts) if ts.len() != expected_count => {
let got = HashSet::<String>::from_iter(ts.into_iter().map(|ts| ts.obj_id));
let expected = HashSet::<String>::from_iter(ids.into_iter());
let expected = HashSet::<String>::from_iter(ids);
let diff = expected.difference(&got).collect::<HashSet<_>>();
return Err(PathfindingError::TrackSectionsNotFound {
track_sections: diff.into_iter().map(|s| s.to_owned()).collect(),
Expand Down Expand Up @@ -221,7 +221,7 @@ fn make_op_map<I: Iterator<Item = String>>(
{
Ok(ts) if ts.len() != expected_count => {
let got = HashSet::<String>::from_iter(ts.into_iter().map(|ts| ts.obj_id));
let expected = HashSet::<String>::from_iter(ids.into_iter());
let expected = HashSet::<String>::from_iter(ids);
let diff = expected.difference(&got).collect::<HashSet<_>>();
return Err(PathfindingError::OperationalPointNotFound {
operational_points: diff.into_iter().map(|s| s.to_owned()).collect(),
Expand Down
2 changes: 1 addition & 1 deletion editoast/src/views/timetable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ async fn get_conflicts(

let mut id_to_name = HashMap::new();
let mut trains_requirements = Vec::new();
for (schedule, simulation) in schedules.into_iter().zip(simulations.into_iter()) {
for (schedule, simulation) in schedules.into_iter().zip(simulations) {
id_to_name.insert(
schedule.id.expect("TrainSchedule should have an id"),
schedule.train_name,
Expand Down

0 comments on commit 8f6aec0

Please sign in to comment.