Added useful methods
This commit is contained in:
1 parent
8fcac39512
commit
f833d95e79
1 file changed
+21
@@ -18,6 +18,27 @@ pub enum FormValue {
|
|||||||
Text(String),
|
Text(String),
|
||||||
VecText(Vec<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 */
|
/* DOMEvent: Send + SyncTarget relatedTarget */
|
||||||
pub struct FormData {
|
pub struct FormData {
|
||||||
|
|||||||
Reference in new issue
Block a user