rustfmt
This commit is contained in:
1 parent
c1fbf31a27
commit
a92d1a9424
2 files changed
+7
-10
No files matched your search
@@ -20,7 +20,7 @@ pub enum FormValue {
|
|||||||
}
|
}
|
||||||
impl Into<Vec<String>> for FormValue {
|
impl Into<Vec<String>> for FormValue {
|
||||||
fn into(self) -> Vec<String> {
|
fn into(self) -> Vec<String> {
|
||||||
match self{
|
match self {
|
||||||
FormValue::Text(s) => vec![s],
|
FormValue::Text(s) => vec![s],
|
||||||
FormValue::VecText(vec) => vec,
|
FormValue::VecText(vec) => vec,
|
||||||
}
|
}
|
||||||
@@ -29,7 +29,7 @@ impl Into<Vec<String>> for FormValue {
|
|||||||
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] {
|
||||||
match self{
|
match self {
|
||||||
FormValue::Text(s) => std::slice::from_ref(s),
|
FormValue::Text(s) => std::slice::from_ref(s),
|
||||||
FormValue::VecText(vec) => vec.as_slice(),
|
FormValue::VecText(vec) => vec.as_slice(),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -395,12 +395,10 @@ impl HasFormData for WebFormData {
|
|||||||
match map.entry(key) {
|
match map.entry(key) {
|
||||||
std::collections::hash_map::Entry::Occupied(mut o) => {
|
std::collections::hash_map::Entry::Occupied(mut o) => {
|
||||||
let first_value = match o.get_mut() {
|
let first_value = match o.get_mut() {
|
||||||
FormValue::Text(data) => {
|
FormValue::Text(data) => std::mem::take(data),
|
||||||
std::mem::take(data)
|
|
||||||
}
|
|
||||||
FormValue::VecText(vec) => {
|
FormValue::VecText(vec) => {
|
||||||
vec.push(new_value);
|
vec.push(new_value);
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let _ = o.insert(FormValue::VecText(vec![first_value, new_value]));
|
let _ = o.insert(FormValue::VecText(vec![first_value, new_value]));
|
||||||
@@ -418,11 +416,10 @@ impl HasFormData for WebFormData {
|
|||||||
if let Ok(array) = value.dyn_into::<Array>() {
|
if let Ok(array) = value.dyn_into::<Array>() {
|
||||||
if let Some(name) = array.get(0).as_string() {
|
if let Some(name) = array.get(0).as_string() {
|
||||||
if let Ok(item_values) = array.get(1).dyn_into::<Array>() {
|
if let Ok(item_values) = array.get(1).dyn_into::<Array>() {
|
||||||
item_values.iter()
|
item_values
|
||||||
|
.iter()
|
||||||
.filter_map(|v| v.as_string())
|
.filter_map(|v| v.as_string())
|
||||||
.for_each(|v| {
|
.for_each(|v| insert_value(&mut values, name.clone(), v));
|
||||||
insert_value(&mut values, name.clone(), v)
|
|
||||||
});
|
|
||||||
} else if let Ok(item_value) = array.get(1).dyn_into::<JsValue>() {
|
} else if let Ok(item_value) = array.get(1).dyn_into::<JsValue>() {
|
||||||
insert_value(&mut values, name, item_value.as_string().unwrap());
|
insert_value(&mut values, name, item_value.as_string().unwrap());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user