Added useful methods

This commit is contained in:
serzhiio 2024-01-15 17:16:44 +04:00
parent 8fcac39512
commit f833d95e79

View file

@ -18,6 +18,27 @@ pub enum FormValue {
Text(String),
VecText(Vec<String>),
}
impl Into<Vec<String>> for FormValue {
fn into(self) -> Vec<String> {
match self{
FormValue::Text(s) => vec![s],
FormValue::VecText(vec) => vec,
}
}
}
impl FormValue {
/// Convenient way to represent Value as slice
pub fn as_slice(&self) -> &[String] {
match self{
FormValue::Text(s) => std::slice::from_ref(s),
FormValue::VecText(vec) => vec.as_slice(),
}
}
/// Convert into Vec<String>
pub fn to_vec(self) -> Vec<String> {
self.into()
}
}
/* DOMEvent: Send + SyncTarget relatedTarget */
pub struct FormData {