You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Consider the following sentence, which is in the crate's root documentation:
All the functions here are guarded by the Pod trait, which is a sub-trait of the Zeroable trait.
What this says to me is:
All the functions in this crate work on types that implement Pod. If a type does not or cannot safely implement Pod, then these functions cannot be used.
The problem is that this just isn't true. I posted a reply to a question on URLO about casting a slice of enum values to a slice of bytes in which I noted the existence of bytemuck, but explicitly warned not to use it because the enum type in question could not safely implement Pod. This warning was based on the above line in the documentation, combined with the description of the requirements of Pod.
However, if I had ignored the documentation and looked deeper, I would have seen the docs for cast_slice, which would lead me to the docs for NoUninit, and I (hopefully) would have realised that the enum could in fact implement NoUninit.
Perhaps the documentation should instead mention all the relevant traits in rough order of weakening, to indicate that there are multiple levels of "support" depending on the safety requirements for the implementing type. Otherwise you'll get dumbasses like me taking you at your word and giving up too easily. :)
The text was updated successfully, but these errors were encountered:
The only change I'd make is replacing "the Pod trait" with "the NoUninit and AnyBitPattern traits" on line 50. If someone sees "Using Your Own Types" and jumps down directly to that, they could miss the previous paragraph and still get the wrong idea.
Also, I'm glad you called out the must_ functions, because I didn't know those existed, and they sound useful. :)
Consider the following sentence, which is in the crate's root documentation:
What this says to me is:
The problem is that this just isn't true. I posted a reply to a question on URLO about casting a slice of enum values to a slice of bytes in which I noted the existence of
bytemuck
, but explicitly warned not to use it because the enum type in question could not safely implementPod
. This warning was based on the above line in the documentation, combined with the description of the requirements ofPod
.However, if I had ignored the documentation and looked deeper, I would have seen the docs for
cast_slice
, which would lead me to the docs forNoUninit
, and I (hopefully) would have realised that the enum could in fact implementNoUninit
.Perhaps the documentation should instead mention all the relevant traits in rough order of weakening, to indicate that there are multiple levels of "support" depending on the safety requirements for the implementing type. Otherwise you'll get dumbasses like me taking you at your word and giving up too easily. :)
The text was updated successfully, but these errors were encountered: