-
Hi, I'm having a hard time understanding an error. impl Vertex {
pub fn desc<'a>() -> wgpu::VertexBufferLayout<'a> {
wgpu::VertexBufferLayout {
array_stride: std::mem::size_of::<Vertex>() as wgpu::BufferAddress,
step_mode: wgpu::InputStepMode::Vertex,
attributes: &wgpu::vertex_attr_array![0 => Float32x3, 1 => Float32x3],
}
}
} The error:
How am I supposed to use the marcro ? And why does the code fail ? |
Beta Was this translation helpful? Give feedback.
Answered by
kvark
Aug 11, 2021
Replies: 1 comment 3 replies
-
Rust is confused and doesn't realize this macro invocation returns a constant expression. impl Vertex {
const ATTRIBS: [wgpu::VertexAttribute; 2] = wgpu::vertex_attr_array![0 => Float32x3, 1 => Float32x3];
pub fn desc<'a>() -> wgpu::VertexBufferLayout<'a> {
wgpu::VertexBufferLayout {
array_stride: std::mem::size_of::<Vertex>() as wgpu::BufferAddress,
step_mode: wgpu::VertexStepMode::Vertex,
attributes: &Self::ATTRIBS,
}
}
} |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
rokonio
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Rust is confused and doesn't realize this macro invocation returns a constant expression.
You can work around by doing this following: