From ccce54c1a3d3ec386e4615d33a0fc9420aaf5b02 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Sun, 5 Jan 2025 21:39:48 -0800 Subject: [PATCH] calculate title at compile time --- strafe-client/src/main.rs | 4 +++- strafe-client/src/setup.rs | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/strafe-client/src/main.rs b/strafe-client/src/main.rs index 337ba79..d580614 100644 --- a/strafe-client/src/main.rs +++ b/strafe-client/src/main.rs @@ -12,6 +12,8 @@ mod model_graphics; mod physics_worker; mod graphics_worker; +const TITLE:&'static str=concat!("Strafe Client v",env!("CARGO_PKG_VERSION")); + fn main(){ - setup::setup_and_start(format!("Strafe Client v{}",env!("CARGO_PKG_VERSION"))); + setup::setup_and_start(TITLE); } diff --git a/strafe-client/src/setup.rs b/strafe-client/src/setup.rs index 790352d..5b3b5b8 100644 --- a/strafe-client/src/setup.rs +++ b/strafe-client/src/setup.rs @@ -192,14 +192,14 @@ pub struct SetupContext<'a>{ pub config:wgpu::SurfaceConfiguration, } -pub fn setup_and_start(title:String){ +pub fn setup_and_start(title:&str){ let event_loop=winit::event_loop::EventLoop::new().unwrap(); println!("Initializing the surface..."); let partial_1=create_instance(); - let window=create_window(title.as_str(),&event_loop).unwrap(); + let window=create_window(title,&event_loop).unwrap(); let partial_2=partial_1.create_surface(&window).unwrap();