From 4c1da84490f1442f51bf44ab5c32e92eb1a273a0 Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Fri, 15 Mar 2024 17:04:00 +0900 Subject: [PATCH] Refactoring: Make some functions "const" in Vertex --- src/math3d.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/math3d.rs b/src/math3d.rs index da17f00..3f19a57 100644 --- a/src/math3d.rs +++ b/src/math3d.rs @@ -22,11 +22,11 @@ impl Vertex { Self { pos, color } } - pub fn pos_offset() -> usize { + pub const fn pos_offset() -> usize { 0 } - pub fn color_offset() -> usize { + pub const fn color_offset() -> usize { let mut offset = std::mem::size_of::<[f32; 2]>(); let alignment = std::mem::align_of::<[f32; 3]>(); while offset % alignment != 0 { @@ -36,7 +36,7 @@ impl Vertex { offset } - pub fn get_binding_description() -> ffi::VkVertexInputBindingDescription { + pub const fn get_binding_description() -> ffi::VkVertexInputBindingDescription { let mut bind_desc: ffi::VkVertexInputBindingDescription = unsafe { std::mem::zeroed() }; bind_desc.binding = 0; @@ -46,7 +46,7 @@ impl Vertex { bind_desc } - pub fn get_attribute_descriptions() -> [ffi::VkVertexInputAttributeDescription; 2] { + pub const fn get_attribute_descriptions() -> [ffi::VkVertexInputAttributeDescription; 2] { let mut attr_descs: [ffi::VkVertexInputAttributeDescription; 2] = unsafe { std::mem::zeroed() };