mirror of
https://github.com/robertwayne/axum-htmx
synced 2024-11-26 05:09:35 +01:00
Take &str instead of String for HxEvent::new_* fns
This commit is contained in:
parent
22e81e0d0b
commit
3928b9f407
1 changed files with 6 additions and 3 deletions
|
@ -161,14 +161,17 @@ pub struct HxEvent {
|
|||
|
||||
impl HxEvent {
|
||||
pub fn new<T: Serialize>(name: String) -> Self {
|
||||
Self { name, data: None }
|
||||
Self {
|
||||
name: name.to_string(),
|
||||
data: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_with_data<T: Serialize>(name: String, data: T) -> Result<Self, serde_json::Error> {
|
||||
pub fn new_with_data<T: Serialize>(name: &str, data: T) -> Result<Self, serde_json::Error> {
|
||||
let data = serde_json::to_value(data)?;
|
||||
|
||||
Ok(Self {
|
||||
name,
|
||||
name: name.to_string(),
|
||||
data: Some(data),
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue