-
Notifications
You must be signed in to change notification settings - Fork 5
Add strong ID type infrastructure + NodeID #129
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
Conversation
So, it is not quite API-preserving:
cc @MomoLangenstein @hyanwong |
Clippy is failing due to rust-lang/rust-bindgen#2049 and rust-lang/rust-bindgen#1651 |
A quick performance check suggests no loss of performance in the example forward sim. |
The much more difficult part is to update |
That is actually a good change in my opinion. I personally dislike when type TskReturnValue<T> = Result<T, TskitError>;
From what I know, that is impossible.
You could add this new trait, add a new function, or implement |
I thought you disabled clippy checks for the auto generated code? Right now, chippy seems to fail on actual compilation errors. Anyways, there are much stronger checks that you could enable for this project. If you’d like, I could open a PR for that after we have finished this one. |
No, clippy hits everything. This issue with bindgen is new to stable/beta. As for a PR w/more checks, that can happen any time. There's no guarantee that this one is getting merged. And, if it does, it won't be anytime soon. There's a lot of nuance here. And even if this does work out, there are 3-4 more downstream PRs needed for all the other ID types. |
In Line 27 in d9abda5
Line 65 in d9abda5
#[allow(clippy::all)]
pub mod bindings; |
I'll try this in a separate PR, as it is a separate issue. It came out of nowhere as I've not done any rust work in months, and these warnings only hit due to a recent update. |
For the record, moving the "allow clippy all" doesn't fix the problem. I just tried this as a standalone change with respect to the main branch. |
Thanks for trying! |
It is quite annoying: |
Now that all tests are passing, I'm going to let this simmer a bit. There are a few nagging issues, but none that can't be handled in a later PR:
|
That’s a good idea - though 1-2 sentences and a link to the newtype pattern might suffice.
In which situations would you want to perform arithmetic on this type? |
Book-keeping of "the next offspring node" is sometimes handing for forward-time simulations. You may say something like x = x + number of births that have happened. But perhaps using i32 and From solves all of that. |
I guess I need to figure out how to do this using rust's doc system. It is a bit limited compared to what we are used to over in Pythonlandia. |
* Implement the pattern via a macro * Add NodeId as the first concrete example This PR breaks API, although the changes required are small. See examples/forward_simulation.rs.
I'm pretty confident that this is the way to go. I'll sort out the other ID types in future PRs, in case we ever need to |
Gonna merge this in a minute--thanks for the input @MomoLangenstein! |
This PR starts a discussion about strengthening the ID types in tskit-rust.
See #128 for background.