implement deref for FormValue
This commit is contained in:
1 parent
6bc2fb0906
commit
a20a85dad6
1 file changed
+11
@@ -1,5 +1,6 @@
|
|||||||
use crate::file_data::FileEngine;
|
use crate::file_data::FileEngine;
|
||||||
use crate::file_data::HasFileData;
|
use crate::file_data::HasFileData;
|
||||||
|
use std::ops::Deref;
|
||||||
use std::{collections::HashMap, fmt::Debug};
|
use std::{collections::HashMap, fmt::Debug};
|
||||||
|
|
||||||
use dioxus_core::Event;
|
use dioxus_core::Event;
|
||||||
@@ -18,6 +19,7 @@ pub enum FormValue {
|
|||||||
Text(String),
|
Text(String),
|
||||||
VecText(Vec<String>),
|
VecText(Vec<String>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<FormValue> for Vec<String> {
|
impl From<FormValue> for Vec<String> {
|
||||||
fn from(value: FormValue) -> Self {
|
fn from(value: FormValue) -> Self {
|
||||||
match value {
|
match value {
|
||||||
@@ -26,6 +28,15 @@ impl From<FormValue> for Vec<String> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Deref for FormValue {
|
||||||
|
type Target = [String];
|
||||||
|
|
||||||
|
fn deref(&self) -> &Self::Target {
|
||||||
|
self.as_slice()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl FormValue {
|
impl FormValue {
|
||||||
/// Convenient way to represent Value as slice
|
/// Convenient way to represent Value as slice
|
||||||
pub fn as_slice(&self) -> &[String] {
|
pub fn as_slice(&self) -> &[String] {
|
||||||
|
|||||||
Reference in new issue
Block a user