shame icon indicating copy to clipboard operation
shame copied to clipboard

`sm::CpuAligned` not implemented for `!Sized + sm::CpuLayout` structs

Open RayMarch opened this issue 6 months ago • 1 comments
trafficstars

the trait sm::CpuAligned is not public and not implemented for !Sized + sm::CpuLayout structs.

as of now, the following code doesn't compile

#[derive(sm::CpuLayout)]
#[repr(C)]
struct Unsized {
    a: f32,
    b: [f32],
}
< Unsized as sm::CpuAligned>::CPU_ALIGNMENT;

Solution:

  • add sm::CpuAligned to the public interface.
  • add an impl block for sm::CpuAligned in the #[derive(sm::CpuLayout)] macro that takes the same bounds as the impl block for sm::CpuLayout and infers the alignment and optional size from the fields.

RayMarch avatar May 07 '25 13:05 RayMarch