Comments (2)
Seems to me that perhaps some confusion is the Zeroable
does not require for ::zeroed
to make logical sense, but rather just that zeroed
cannot cause the type to expose unsafe behavior, which are quite different requirements. Though perhaps @repi already realizes that and I'm missing something, haha. This does mean that having zeroed
method exposed when deriving Zeroable
is a bit inconvenient if we don't actually want users readily creating the zeroed version. But, the user would have to import the Zeroable
trait to access it anyway, so I don't think it's a huge deal.
from bytemuck.
If the type is Pod, that means you're allowed to cast [u8; N]
into that type, where N is however many bytes that type is.
Supposing that the array contains all 0 values, then you'd have made the zeroed instance of that type.
Thus, while it might not be useful to have a zeroed instance of the type, it must be legal for that instance to exist. If it's not legal, then the type shouldn't be Pod in the first place.
from bytemuck.
Related Issues (20)
- `TransparentWrapper` derive unsoundness HOT 12
- cast_slice on a memory-mapped file fails on Windows but succeeds on Linux HOT 4
- `#[repr(transparent)]` wrapper around `[u8]` DST HOT 1
- Suboptimal assembly for Contiguous derive HOT 9
- Should `pod_collect_to_vec()` input type require `AnyBitPattern`? HOT 8
- Derive gives `clippy::extra_unused_type_parameters` warnings HOT 4
- Mark try_from_bytes function as unsafe HOT 4
- consider updating to syn 2.0.0 HOT 2
- use #[inline(always)] instead of #[inline] HOT 3
- Consider adding `doc(hidden)` to impl details? HOT 1
- Allow deriving `Zeroable` with explicitly provided bounds HOT 11
- Allow deriving `Pod` for structs where generics are used only as `PhantomData` HOT 2
- Derive macro doesn't work when exported HOT 1
- Fails to compile with rustc 1.72.0-nightly (fe7454bf4 2023-06-19) HOT 8
- Raw pointer cast functions HOT 4
- Cannot use derive macros when reexporting bytemuck from library HOT 2
- Crate makes assumptions about bool values HOT 5
- Safe `offset_of` for packed structs using `addr_of`? HOT 9
- `ASSERT_SIZE_MULTIPLE_OF` when casting `&[u8]` to `&[[u8; 16]]` HOT 1
- Crate documentation is misleading, implies `Pod` required for all functions. HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bytemuck.