-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
improve contributors compatibility #99
improve contributors compatibility #99
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks ! I've 2 small comments and a question :)
src/gtfs/read.rs
Outdated
@@ -744,10 +750,11 @@ fn get_modes_from_gtfs( | |||
.iter() | |||
.map(|mt| get_commercial_mode(mt)) | |||
.collect(); | |||
let physical_modes = gtfs_mode_types | |||
let physical_modes_set: HashSet<objects::PhysicalMode> = gtfs_mode_types |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should remove the explicit type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it has to be there otherwise it gets a vector, we use hashset first to remove duplicate and then transform to a vector for function return
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it cannot infer if he removes the type but he can write HashSet<_>
src/gtfs/read.rs
Outdated
.iter() | ||
.map(|mt| get_physical_mode(mt)) | ||
.collect(); | ||
let physical_modes: Vec<objects::PhysicalMode> = physical_modes_set.into_iter().collect(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here yes you can remove Vec<objects::PhysicalMode>
} | ||
} | ||
|
||
impl Eq for PhysicalMode {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it ok and useful to declare impl
without any function ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it has to be there but i guess it uses the declaration from the trait PartialEq
Eq has no extra methods, it is only informing the compiler that this is an equivalence relation rather than a partial equivalence relation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the reply 👍
src/gtfs/read.rs
Outdated
#[derive(Derivative)] | ||
#[derivative(Default(bound = ""))] | ||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Hash)] | ||
#[derive(Derivative, Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Hash)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can add
#[derivative(Default)]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
src/gtfs/read.rs
Outdated
#[serde(rename = "2")] | ||
StopEntrace, | ||
} | ||
|
||
impl Default for StopLocationType { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can remove this implementation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
src/gtfs/read.rs
Outdated
@@ -744,10 +750,11 @@ fn get_modes_from_gtfs( | |||
.iter() | |||
.map(|mt| get_commercial_mode(mt)) | |||
.collect(); | |||
let physical_modes = gtfs_mode_types | |||
let physical_modes_set: HashSet<objects::PhysicalMode> = gtfs_mode_types |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it cannot infer if he removes the type but he can write HashSet<_>
src/gtfs/read.rs
Outdated
.iter() | ||
.map(|mt| get_physical_mode(mt)) | ||
.collect(); | ||
let physical_modes: Vec<objects::PhysicalMode> = physical_modes_set.into_iter().collect(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here yes you can remove Vec<objects::PhysicalMode>
@@ -1446,6 +1454,41 @@ mod tests { | |||
}); | |||
} | |||
|
|||
#[test] | |||
fn gtfs_trips_no_direction_id() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this test seems similar to test gtfs_trips()
you modify it instead of create a new one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as the title says it tests the trips with no column direction_id
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok but in gtfs_trips()
there is the same fixture with no direction id.
I thought you might add an assertion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the trips file with no direction_id for a row does not make the same test as the missing column, that's why i added a new test with a missing column
079ae8d
to
2065388
Compare
src/gtfs/read.rs
Outdated
.iter() | ||
.map(|mt| get_physical_mode(mt)) | ||
.collect(); | ||
let physical_modes = physical_modes_set.into_iter().collect(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let physical_modes = gtfs_mode_types
.iter()
.map(|mt| get_physical_mode(mt))
.collect::<BTreeSet<_>>()
.into_iter()
.collect();
BTreeSet because it will have a deterministic order.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
order by id? or co2_emission?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
order by Ord
@@ -523,7 +522,7 @@ pub fn read_stops<P: AsRef<path::Path>>( | |||
let comment_links = manage_comment_from_stop(comments, &stop); | |||
let equipment_id = get_equipment_id_and_populate_equipments(equipments, &stop); | |||
match stop.location_type { | |||
StopLocationType::StopArea => { | |||
StopLocationType::StopPoint => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💩
@@ -173,3 +173,15 @@ where | |||
obj.add_prefix(prefix); | |||
} | |||
} | |||
|
|||
macro_rules! skip_fail { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like this macro: it's too dependent of the context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should i change the name or just remove the macro?
6d936e4
to
bec0150
Compare
Fix #97 and compatibility with several contributors