We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Can cast [f32; 5] as Data { a: f32, b: [f32; 3], c: f32 }
[f32; 5]
{ a: f32, b: [f32; 3], c: f32 }
#[repr(C)] #[derive(Clone, Copy)] struct Data { a: f32, b: [f32; 3], c: f32, } union DataOrArray { arr: [f32; 5], str: Data, } impl DataOrArray { fn arr(self) -> [f32; 5] { unsafe { self.arr } } fn new(arr: [f32; 5]) -> Self { Self { arr } } }
in shader:
let dora = DataOrArray::new([0.0, 0.0, 0.0, 0.0, 0.0]); let arr = dora.arr();
Produces:
error: cannot cast between pointer types from `*struct types::Data { a: f32, b: [f32; 3], c: f32 }` to `*[f32; 5]`
The text was updated successfully, but these errors were encountered:
Can you try latest master? I landed 2f915a0 which fixed issues with a similar message (#46) and I think this is fixed by it too.
Sorry, something went wrong.
Nope, even at commit 2f915a0 error still appears
I tried trick it with core::mem::transmute:
core::mem::transmute
pub fn arr(self) -> [f32; 5] { unsafe { core::mem::transmute(self) } }
Error:
error: cannot memcpy dynamically sized data --> solver/src/types/data_or_array.rs:16:18 | 16 | unsafe { core::mem::transmute(self) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^
I created repo to test this error, but it failed to compile #242
Ok great, I'll take a look.
simensgreen
No branches or pull requests
Expected Behaviour
Can cast
[f32; 5]
as Data{ a: f32, b: [f32; 3], c: f32 }
Example & Steps To Reproduce
in shader:
Produces:
System Info
The text was updated successfully, but these errors were encountered: