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

Don't unnecessarily borrow &self as mutable #125

Merged
merged 1 commit into from Dec 27, 2023

Conversation

valadaptive
Copy link
Contributor

This might be a breaking change under semver rules--I don't know enough to be confident.

The get_noise functions don't actually need to borrow self mutably, and doing so can be somewhat limiting. For instance, I want to generate noise in parallel on multiple threads. That cannot be done with &mut self, as Rust treats that as an indication that that function mutates some shared state within the generator, which cannot be done safely on multiple threads.

However, since these functions don't actually mutate any internal state, they're perfectly safe to call from multiple threads at once--Rust just doesn't know it. That's what this PR fixes.

@Keavon
Copy link
Contributor

Keavon commented Dec 27, 2023

Ah, yes, good fix! I don't think this would be a breaking change because existing callers, I'm pretty sure, shouldn't have any trouble using their existing code.

@Auburn Auburn merged commit df34389 into Auburn:master Dec 27, 2023
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.

None yet

3 participants