From ad059455079300e80f97565325aebab0b3b49bba Mon Sep 17 00:00:00 2001 From: patoche Date: Fri, 26 Mar 2021 09:14:39 +0100 Subject: [PATCH] [tech] Update to clippy 1.51 --- ntfs2gtfs/src/lib.rs | 2 +- src/model.rs | 8 ++++---- src/ntfs/mod.rs | 4 ++-- src/ntfs/read.rs | 2 +- src/ntfs/write.rs | 2 +- src/objects.rs | 16 ++++++++-------- src/transfers.rs | 2 +- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/ntfs2gtfs/src/lib.rs b/ntfs2gtfs/src/lib.rs index 81e69ac08..c391cd189 100644 --- a/ntfs2gtfs/src/lib.rs +++ b/ntfs2gtfs/src/lib.rs @@ -31,5 +31,5 @@ pub fn add_mode_to_line_code(model: Model) -> Result { line.code = code; } - Ok(Model::new(collections)?) + Model::new(collections) } diff --git a/src/model.rs b/src/model.rs index 7946d6455..092e0905b 100644 --- a/src/model.rs +++ b/src/model.rs @@ -101,7 +101,7 @@ pub struct Collections { //HashMap<(vehicle_journey_id, stop_sequence), comment_id> pub stop_time_comments: HashMap<(String, u32), String>, pub prices_v1: Collection, - pub od_fares_v1: Collection, + pub od_fares_v1: Collection, pub fares_v1: Collection, pub tickets: CollectionWithId, pub ticket_uses: CollectionWithId, @@ -1484,7 +1484,7 @@ mod tests { // - stop_point_idx (usize -> index of one of the four test stop points) // - arrival_time (Time) // - departure_time (Time) - type VJConfig = (String, usize, Time, Time); + type VjConfig = (String, usize, Time, Time); // This creates 2 vehicle journeys, each with 2 stop times. There is 4 // available test stop points 'sp0' ―▶ 'sp3'. First vehicle journey has @@ -1492,8 +1492,8 @@ mod tests { // 'prev_vj_config'. Second vehicle journey has a first stop time // configurable with 'next_vj_config' and second stop time with 'sp3'. fn build_vehicle_journeys( - prev_vj_config: VJConfig, - next_vj_config: VJConfig, + prev_vj_config: VjConfig, + next_vj_config: VjConfig, ) -> CollectionWithId { let mut stop_points = CollectionWithId::default(); let mut sp_idxs = Vec::new(); diff --git a/src/ntfs/mod.rs b/src/ntfs/mod.rs index 66fa79ce0..9748f3394 100644 --- a/src/ntfs/mod.rs +++ b/src/ntfs/mod.rs @@ -1390,7 +1390,7 @@ mod tests { #[test] fn od_fares_v1_serialization_deserialization() { test_serialize_deserialize_collection(vec![ - ODFareV1 { + OdFareV1 { origin_stop_area_id: "stop_area:0:SA:8727114".to_string(), origin_name: Some("EPINAY-S/SEINE".to_string()), origin_mode: "stop".to_string(), @@ -1399,7 +1399,7 @@ mod tests { destination_mode: "stop".to_string(), ticket_id: "29".to_string(), }, - ODFareV1 { + OdFareV1 { origin_stop_area_id: "stop_area:0:SA:8773006".to_string(), origin_name: None, origin_mode: "zone".to_string(), diff --git a/src/ntfs/read.rs b/src/ntfs/read.rs index 2604e2a76..81dbce19e 100644 --- a/src/ntfs/read.rs +++ b/src/ntfs/read.rs @@ -232,7 +232,7 @@ pub fn manage_fares_v1(collections: &mut Collections, base_path: &path::Path) -> .with_context(|_| format!("Error reading {:?}", path))?; let od_fares_v1 = rdr .deserialize() - .collect::, _>>() + .collect::, _>>() .with_context(|_| format!("Error reading {:?}", path))?; collections.od_fares_v1 = Collection::new(od_fares_v1); diff --git a/src/ntfs/write.rs b/src/ntfs/write.rs index 7125e8e22..290399263 100644 --- a/src/ntfs/write.rs +++ b/src/ntfs/write.rs @@ -135,7 +135,7 @@ pub fn write_vehicle_journeys_and_stop_times( fn do_write_fares_v1( base_path: &path::Path, prices_v1: &Collection, - od_fares_v1: &Collection, + od_fares_v1: &Collection, fares_v1: &Collection, ) -> Result<()> { let file_prices = "prices.csv"; diff --git a/src/objects.rs b/src/objects.rs index 2ecd44f0e..b0edacaa9 100644 --- a/src/objects.rs +++ b/src/objects.rs @@ -923,6 +923,12 @@ impl From for (String, String) { } } +impl From for GeoPoint { + fn from(coord: Coord) -> Self { + GeoPoint::new(coord.lon, coord.lat) + } +} + // Mean Earth radius in meters const EARTH_RADIUS: f64 = 6_371_000.0; @@ -935,12 +941,6 @@ impl From> for Coord { } } -impl Into> for Coord { - fn into(self) -> GeoPoint { - GeoPoint::new(self.lon, self.lat) - } -} - impl Coord { /// Calculate the orthodromic distance in meters /// between 2 geographic coordinates @@ -1589,7 +1589,7 @@ impl AddPrefix for PriceV1 { } #[derive(Serialize, Deserialize, Debug, PartialEq, Eq, PartialOrd, Ord)] -pub struct ODFareV1 { +pub struct OdFareV1 { #[serde(rename = "Origin ID")] pub origin_stop_area_id: String, #[serde(rename = "Origin name")] @@ -1605,7 +1605,7 @@ pub struct ODFareV1 { pub ticket_id: String, } -impl AddPrefix for ODFareV1 { +impl AddPrefix for OdFareV1 { fn prefix(&mut self, prefix_conf: &PrefixConfiguration) { self.ticket_id = prefix_conf.referential_prefix(self.ticket_id.as_str()); self.origin_stop_area_id = diff --git a/src/transfers.rs b/src/transfers.rs index fa69d52aa..4536feddb 100644 --- a/src/transfers.rs +++ b/src/transfers.rs @@ -146,5 +146,5 @@ pub fn generates_transfers( let mut collections = model.into_collections(); collections.transfers = Collection::new(new_transfers); - Ok(Model::new(collections)?) + Model::new(collections) }