Skip to content
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

Support for PartialEq and Eq for objects with an id #18

Merged
merged 8 commits into from
Sep 9, 2018
Merged

Support for PartialEq and Eq for objects with an id #18

merged 8 commits into from
Sep 9, 2018

Conversation

ASalvail
Copy link
Collaborator

@ASalvail ASalvail commented Sep 7, 2018

This PR adds methods to fetch ids on the object where this was missing.

Given those, it also implements PartialEq and Eq for all objects with an id.
Finally, it also adds PartialEq and Eq for Room based on name.

All of this for partitioning creeps by rooms...

Copy link
Collaborator

@daboross daboross left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall good, glad to have this!

There's one line in the comment for impl_structure_properties! which seems out of place (see my comment on it) but besides that 👍.

screeps-game-api/src/objects/impls/creep.rs Show resolved Hide resolved
screeps-game-api/src/objects/impls/creep.rs Show resolved Hide resolved
@@ -86,3 +86,33 @@ macro_rules! impl_room_object_properties {
)*
);
}


// Macro for mass implementing `StructureProperties`, `PartialEq` and `Eq` for a type.
Copy link
Collaborator

@daboross daboross Sep 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could be a doc comment with //! ///, but it's not a big deal.

Edit: I'd completely forgotten the difference between //! and /// while reviewing these prs.

The main reason I like doc comments for this sort of thing is that it syntactically attaches the comment to the macro. Even if it's just internal comments for an internal macro, it makes it even clearer that this comment is for the thing under it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the // for ///, but I'll wait until #19 is merged before moving this one with the other.

screeps-game-api/src/objects/impls/creep.rs Show resolved Hide resolved
//
// # Example
// ```
// macro_rules!(OwnedStructure, Structure, StructureContainer)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless I'm missing something, I think this line was meant to be something else?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The copy/paste monster is real!

@daboross
Copy link
Collaborator

daboross commented Sep 8, 2018

Glad to have you improving this repo! Hope my PR reviews aren't too scrutinous.

@ASalvail
Copy link
Collaborator Author

ASalvail commented Sep 8, 2018

Absolutely not, it's all very constructive. Still learning the ropes of rust (which I really like), so your comments help me getting a feel for what is usually left unsaid and best practices.

Thanks for taking the time to review my small avalanche of PRs!

@daboross
Copy link
Collaborator

daboross commented Sep 9, 2018

Glad to hear it's constructive!

Reviewing a small avalanche of PRs is only a tiny bit of work compared to the benefit of extra eyes on the project and the contributions themselves. Thanks for coming and improve screeps-game-api!

@daboross
Copy link
Collaborator

daboross commented Sep 9, 2018

I'll merge this manually since the changes in src/objects/macros.rs conflict with the macro cleanup.

@ASalvail
Copy link
Collaborator Author

ASalvail commented Sep 9, 2018

Thanks! I was going through the changes. I'll leave it to you.
We should coordinate on slack next time 🤔

@daboross
Copy link
Collaborator

daboross commented Sep 9, 2018

Ah yeah- that could work!

@daboross daboross merged commit 5464ad0 into rustyscreeps:master Sep 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants