From f903801ba8d746518b413ad60234377a61953232 Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Sun, 1 Dec 2024 16:02:14 -0600 Subject: [PATCH] Simplify exploration code. --- src/exploration.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/exploration.rs b/src/exploration.rs index 1c41297..93ce86e 100644 --- a/src/exploration.rs +++ b/src/exploration.rs @@ -1,4 +1,9 @@ -use std::{error::Error, fmt::Debug, hash::Hash, marker::PhantomData}; +use std::{ + error::Error, + fmt::{Debug, Display}, + hash::Hash, + marker::PhantomData, +}; use bevy::prelude::*; use bevy_rapier2d::prelude::*; @@ -182,7 +187,7 @@ fn exploration_type_changed_announcement( >, ) -> Result<(), Box> where - ExplorationType: Component + Default + Copy + Into, + ExplorationType: Component + Default + Copy + Display, { for (focused, changed) in &focused { if changed.is_added() { @@ -190,8 +195,7 @@ where } match &focused.0 { Some(v) => { - let v: String = (*v).into(); - tts.speak(v, true)?; + tts.speak(format!("{v}"), true)?; } None => { tts.speak("Everything", true)?; @@ -284,7 +288,7 @@ fn exploration_changed_announcement( rapier_context: Res, ) -> Result<(), Box> where - ExplorationType: Component + Copy + Into, + ExplorationType: Component + Copy + Display, MapData: 'static + Clone + Default + Send + Sync, { if let Ok((coordinates, exploring, viewshed)) = explorer.get_single() { @@ -318,7 +322,7 @@ where } if tokens.is_empty() { if let Ok(t) = types.get(entity) { - tokens.push((*t).into()); + tokens.push(format!("{t}")); } } } @@ -385,7 +389,7 @@ pub struct Exploration; impl Plugin for ExplorationPlugin where - ExplorationType: 'static + Component + Default + Copy + Ord + PartialEq + Into, + ExplorationType: 'static + Component + Default + Copy + Ord + PartialEq + Display, MapData: 'static + Clone + Default + Send + Sync, { fn build(&self, app: &mut App) {