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

[Rust] Added clone derive for FastNoiseLite #138

Merged
merged 2 commits into from
May 6, 2024

Conversation

DanielDK05
Copy link
Contributor

"It ain't much, but it's honest work"

Added a clone derive, as cloning is necessary in some cases.

N.B: the other changes in the file came from cargo fmt

@Auburn
Copy link
Owner

Auburn commented May 6, 2024

@Keavon does this look good to you?

@Keavon
Copy link
Contributor

Keavon commented May 6, 2024

Yep, this looks sensible. While we're at it, @DanielDK05 are there any other traits this ought to implement? I'm thinking probably not to Copy since it's a somewhat large struct (48 bytes) and the default move semantics would be preferable for performance reasons.

@DanielDK05
Copy link
Contributor Author

DanielDK05 commented May 6, 2024

@Keavon
Yeah I agree with not adding Copy. Debug might be useful at some point though. Maybe we could also do Serialize/Deserialize from serde, in case anyone would want to have noise configured in a file.

I also thought of Send & Sync for multithreading, but I haven't done much multithreading in rust, so I'm not totally sure how to safely implement that.
I know it's often done simple like this:

unsafe impl Send for FastNoiseLite {}
unsafe impl Sync for FastNoiseLite {}

But the unsafe makes me nervous to implement it myself :D

@Keavon
Copy link
Contributor

Keavon commented May 6, 2024

Maybe let's just go with Debug for now. If someone wants serde for this, they could bother adding it as an optional dependency in a future PR. Likewise, I'm unfamiliar with multithreading so it's probably best to leave that hornet nest for someone who needs it in a future PR.

@DanielDK05
Copy link
Contributor Author

Yeah okay, I'll look at Debug.

@Keavon
Copy link
Contributor

Keavon commented May 6, 2024

Looks good. @Auburn should this also bump the Rust crate's minor version or will you do that in a commit to master after this PR is merged?

@Auburn
Copy link
Owner

Auburn commented May 6, 2024

This was also mentioned as a potential change, don't know if we want that but should wait on it before the version if so #137

@Auburn Auburn merged commit 6fd081a into Auburn:master May 6, 2024
@DanielDK05 DanielDK05 deleted the add_clone_derive branch May 7, 2024 12:35
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.

3 participants