Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Optionally implement bytemuck::Zeroable, for safe zero-allocation #287

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

eira-fransham
Copy link

Closes #286.

We only use derive(Zeroable) in one place, as the atomic integer types don't implement bytemuck::Zeroable at time of writing. This appears to be an oversight in bytemuck.

The Zeroable trait only specifies that the type can be created with an all-zeroes bit pattern, and so this cannot be abused to overwrite the locks with all-zeroes (although doing so would require &mut access anyway).

@Amanieu
Copy link
Owner

Amanieu commented Jun 23, 2021

Do you think you could send a PR to bytemuck to support atomic types? That way we can just use #[derive(Zeroable)] everywhere.

@Amanieu
Copy link
Owner

Amanieu commented Jun 23, 2021

Can you document the feature in README. It's a bit confusing that we have both bytemuck and bytemuck_traits features, but that's an unfortunate cargo limitation.

@bjorn3
Copy link
Contributor

bjorn3 commented Jun 23, 2021

Having the feature called "bytemuck" works on nightly with -Znamespaced-features through bytemuck = ["dep:bytemuck", "lock-api/bytemuck"] I believe.

@nolanderc
Copy link

Zeroable has been implemented for Atomic* types in Lokathor/bytemuck#157

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement bytemuck traits where appropriate
4 participants