Skip to content

Commit 3a2b863

Browse files
leovalaisflomonster
authored andcommitted
editoast: fix clippy warnings
1 parent 1f806fd commit 3a2b863

File tree

3 files changed

+5
-11
lines changed

3 files changed

+5
-11
lines changed

editoast/src/schema/railjson.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,7 @@ pub mod test {
176176
assert!(check_objects_eq(&s_railjson.detectors, &railjson.detectors));
177177
}
178178

179-
fn check_objects_eq<T: PartialEq + OSRDIdentified>(
180-
objects: &Vec<T>,
181-
expected: &Vec<T>,
182-
) -> bool {
179+
fn check_objects_eq<T: PartialEq + OSRDIdentified>(objects: &[T], expected: &[T]) -> bool {
183180
assert_eq!(objects.len(), expected.len());
184181
let map_expected: HashMap<_, _> = expected.iter().map(|obj| (obj.get_id(), obj)).collect();
185182

editoast/src/views/infra/objects.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::collections::HashMap;
1+
use std::collections::{HashMap, HashSet};
22

33
use actix_web::dev::HttpServiceFactory;
44
use actix_web::post;
@@ -31,11 +31,8 @@ enum GetObjectsErrors {
3131
}
3232

3333
/// Return whether the list of ids contains unique values or has duplicate
34-
fn has_unique_ids(obj_ids: &Vec<String>) -> bool {
35-
let mut obj_ids_2 = obj_ids.clone();
36-
obj_ids_2.sort();
37-
obj_ids_2.dedup();
38-
obj_ids_2.len() == obj_ids.len()
34+
fn has_unique_ids(obj_ids: &[String]) -> bool {
35+
obj_ids.len() == obj_ids.iter().collect::<HashSet<_>>().len()
3936
}
4037

4138
#[derive(QueryableByName, Debug, Clone, Serialize, Deserialize, PartialEq)]

editoast/src/views/infra/pathfinding.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ fn compute_path(
313313
.collect()
314314
}
315315

316-
fn build_path_output(path: &Vec<PathfindingStep>, infra_cache: &InfraCache) -> PathfindingOutput {
316+
fn build_path_output(path: &[PathfindingStep], infra_cache: &InfraCache) -> PathfindingOutput {
317317
// Fill track ranges
318318
let mut track_ranges = Vec::new();
319319
// We ignore the first element of path, as it is a virtual step to handle going in both directions

0 commit comments

Comments
 (0)