mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-26 22:20:19 +00:00
Added useful methods
This commit is contained in:
parent
8fcac39512
commit
f833d95e79
1 changed files with 21 additions and 0 deletions
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue