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), }) }