rust-lang / project-safe-transmute

Project group working on the "safe transmute" feature

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Why does the cast_slice parameter have to be of type Pod?

kwinz opened this issue · comments

commented

pub fn try_cast_slice<A: Pod, B: Pod>(a: &[A]) -> Result<&[B], PodCastError>
requires that the parameter a is a slice of type Pod. Pods can't be chars (because the type must allow any bit pattern).

However I don't understand why. It's not like I can introduce illegal bit patterns through a non-mutable reference?!
Is this some random limitiation of this crate?

Can we not fix this because of #41?
Is relaxing trait boundaries not allowed?

Did you mean to file this issue on bytemuck?

This repo isn't for a crate; it tracks an effort to add a new analysis to rust itself.

commented

Yes you are right @jswrenn . Somehow I accidentally opened the issue in the wrong repository. And moreover since at least version 1.9.0 bytemuck actually changed the signature to take NoUninit instead of Pod to address exactly that. So the whole issue is moot in the first place.
I really shouldn't open issues when tired. I would appreciate if you delete this issue. Sorry for the noise!