- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 359
Add Split-Operator in Rust #686
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
Add Split-Operator in Rust #686
Conversation
I don't know rust enough to be able to review it, but I think @Liikt can help you. |
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.
Code looks good to me. 👍
let mut density: Vec<f64>; | ||
|
||
for i in 0..par.timesteps { | ||
// this should use an iterator |
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.
Not sure how you turn this into an iterator as you need the index for accessing a different array than the one you are iterating over. Not saying it is impossible, just harder. I think this is perfectly fine. This also makes the code a bit clearer.
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 just realized I could've used the enumerate()
method, but (as you point out) that may come at the cost of clarity.
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.
Honestly, I don't mind using that either. It just depends on what Rust users are used to reading.
Cool, I am happy to merge if @fanninpm is happy as well. Maybe remove the Thanks for hopping in folks! Also, no problem if you want to keep fiddling with it! |
The small for-loops are fine as they are.
If you guys think this is fine as is, I'm happy to see it merged. |
I'll do a final look-over later. Probably on stream. |
I ran this locally and got the expected results, so it is good to merge as soon as you are happy with the code (just let me know if you want to use As a question, I am not good with rust, how do you normally compile this type of stuff? Would it be worth adding a cargo.toml file or something? |
If this were in a standalone project, I would be using a Since I didn't want to disturb the existing directory structure, I developed this on repl.it. Per #691, if you want to add a
|
I am happy with this PR as is, great work! Thanks for the code! |
@Gathros and @strega-nil do you want to help make this code more rusty, especially with those very short for-loops. (I essentially translated the preexisting C++ implementation and kept fighting the borrow checker until it worked.)