From 0eb210eafe9f89d8df4ab12975c98cda79f0341e Mon Sep 17 00:00:00 2001 From: Muhammad Nauman Raza Date: Wed, 29 Nov 2023 22:40:30 +0000 Subject: [PATCH] feat: move helper functions to a separate file Former-commit-id: 4f173e40b700e633d8bf6ac85970f5f5f7412ff0 --- src/helpers.rs | 9 +++++++++ src/main.rs | 11 +++-------- 2 files changed, 12 insertions(+), 8 deletions(-) create mode 100644 src/helpers.rs diff --git a/src/helpers.rs b/src/helpers.rs new file mode 100644 index 0000000..1354ef1 --- /dev/null +++ b/src/helpers.rs @@ -0,0 +1,9 @@ +use crate::helpers; + +pub fn titlecase(s: &str) -> String { + let mut c = s.chars(); + match c.next() { + None => String::new(), + Some(f) => f.to_uppercase().collect::() + c.as_str(), + } +} diff --git a/src/main.rs b/src/main.rs index b73e9cc..2ec1759 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,6 +9,9 @@ use bevy::{ use std::collections::HashMap; use lazy_static::lazy_static; +mod helpers; +use crate::helpers::*; + const VERSION: &str = env!("CARGO_PKG_VERSION"); const PKGNAME: &str = env!("CARGO_PKG_NAME"); @@ -31,14 +34,6 @@ lazy_static!{ ].iter().copied().collect(); } -fn titlecase(s: &str) -> String { - let mut c = s.chars(); - match c.next() { - None => String::new(), - Some(f) => f.to_uppercase().collect::() + c.as_str(), - } -} - fn main() { App::new() // Only run the app when there is user input, significantly reducing CPU/GPU usage