From 3928b9f40722d0bdcc1610167e57f57a3f3a3ac7 Mon Sep 17 00:00:00 2001 From: Rob Wagner Date: Mon, 23 Oct 2023 21:04:06 -0400 Subject: [PATCH] Take &str instead of String for HxEvent::new_* fns --- src/responders/serde.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/responders/serde.rs b/src/responders/serde.rs index 7de1009..8a3a06e 100644 --- a/src/responders/serde.rs +++ b/src/responders/serde.rs @@ -161,14 +161,17 @@ pub struct HxEvent { impl HxEvent { pub fn new(name: String) -> Self { - Self { name, data: None } + Self { + name: name.to_string(), + data: None, + } } - pub fn new_with_data(name: String, data: T) -> Result { + pub fn new_with_data(name: &str, data: T) -> Result { let data = serde_json::to_value(data)?; Ok(Self { - name, + name: name.to_string(), data: Some(data), }) }