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

Add functions to allocate zeroed Arc and Rc #283

Merged
merged 1 commit into from
Nov 12, 2024

Conversation

a1phyr
Copy link
Contributor

@a1phyr a1phyr commented Nov 5, 2024

These require rustc 1.82

Copy link
Contributor

@zachs18 zachs18 left a comment

Choose a reason for hiding this comment

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

so that this will still compile on targets without Arc

src/allocation.rs Outdated Show resolved Hide resolved
src/allocation.rs Outdated Show resolved Hide resolved
@zachs18
Copy link
Contributor

zachs18 commented Nov 5, 2024

Also: IIUC it is currently up in the air if it is valid to write to the pointer returned from {Arc,Rc}::as_ptr: rust-lang/rust#87862 rust-lang/rust#104337 , so ideally these would use {Arc,Rc}::get_mut(&mut arc).unwrap() at least until that is clarified1.

Footnotes

  1. The compiler can optimize out the unwrap panic branch for Rc but not Arc, but it should still never be possible to panic at runtime since the Arc is newly allocated

@a1phyr
Copy link
Contributor Author

a1phyr commented Nov 6, 2024

As you wish. I updated the code to use write_zeroes and fill_zeroes, it is cleaner like that if we use get_mut

@Lokathor Lokathor merged commit 13f4ae0 into Lokathor:main Nov 12, 2024
14 checks passed
@a1phyr a1phyr deleted the zeroed_rc branch November 19, 2024 10:00
@Lokathor Lokathor added semver-minor semver minor change and removed not yet released labels Nov 19, 2024
@Lokathor
Copy link
Owner

released in bytemuck-1.20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-minor semver minor change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants