|
1 |
| -use crate::ast::{MaybeSpanned, Span}; |
| 1 | +use crate::ast::Span; |
2 | 2 | use itertools::Itertools;
|
3 | 3 | use serde::{Deserialize, Serialize};
|
4 | 4 | use std::{convert::TryFrom, fmt, iter::FromIterator};
|
@@ -26,12 +26,6 @@ impl ConversionError {
|
26 | 26 | #[derive(Clone, Deserialize, Serialize, Default, Eq)]
|
27 | 27 | pub struct DynVal(pub String, pub Option<Span>);
|
28 | 28 |
|
29 |
| -impl MaybeSpanned for DynVal { |
30 |
| - fn try_span(&self) -> Option<Span> { |
31 |
| - self.1 |
32 |
| - } |
33 |
| -} |
34 |
| - |
35 | 29 | impl From<String> for DynVal {
|
36 | 30 | fn from(s: String) -> Self {
|
37 | 31 | DynVal(s, None)
|
@@ -98,7 +92,7 @@ impl_try_from!(impl From<DynVal> {
|
98 | 92 | for f64 => |x| x.as_f64();
|
99 | 93 | for i32 => |x| x.as_i32();
|
100 | 94 | for bool => |x| x.as_bool();
|
101 |
| - for Vec<String> => |x| x.as_vec(); |
| 95 | + //for Vec<String> => |x| x.as_vec(); |
102 | 96 | });
|
103 | 97 |
|
104 | 98 | impl_primval_from!(bool, i32, u32, f32, u8, f64, &str);
|
@@ -145,26 +139,24 @@ impl DynVal {
|
145 | 139 | self.0.parse().map_err(|e| ConversionError::new(self.clone(), "bool", Box::new(e)))
|
146 | 140 | }
|
147 | 141 |
|
148 |
| - pub fn as_vec(&self) -> Result<Vec<String>> { |
149 |
| - match self.0.strip_prefix('[').and_then(|x| x.strip_suffix(']')) { |
150 |
| - Some(content) => { |
151 |
| - let mut items: Vec<String> = content.split(',').map(|x: &str| x.to_string()).collect(); |
152 |
| - let mut removed = 0; |
153 |
| - for times_ran in 0..items.len() { |
154 |
| - // escapes `,` if there's a `\` before em |
155 |
| - if items[times_ran - removed].ends_with('\\') { |
156 |
| - items[times_ran - removed].pop(); |
157 |
| - let it = items.remove((times_ran + 1) - removed); |
158 |
| - items[times_ran - removed] += ","; |
159 |
| - items[times_ran - removed] += ⁢ |
160 |
| - removed += 1; |
161 |
| - } |
162 |
| - } |
163 |
| - Ok(items) |
164 |
| - } |
165 |
| - None => Err(ConversionError { value: self.clone(), target_type: "vec", source: None }), |
166 |
| - } |
167 |
| - } |
| 142 | + // pub fn as_vec(&self) -> Result<Vec<String>> { |
| 143 | + // match self.0.strip_prefix('[').and_then(|x| x.strip_suffix(']')) { |
| 144 | + // Some(content) => { |
| 145 | + // let mut items: Vec<String> = content.split(',').map(|x: &str| x.to_string()).collect(); |
| 146 | + // let mut removed = 0; |
| 147 | + // for times_ran in 0..items.len() { |
| 148 | + //// escapes `,` if there's a `\` before em |
| 149 | + // if items[times_ran - removed].ends_with('\\') { |
| 150 | + // items[times_ran - removed].pop(); |
| 151 | + // let it = items.remove((times_ran + 1) - removed); |
| 152 | + // items[times_ran - removed] += ","; |
| 153 | + // items[times_ran - removed] += ⁢ |
| 154 | + // removed += 1; |
| 155 | + //} |
| 156 | + // Ok(items) |
| 157 | + //} |
| 158 | + // None => Err(ConversionError { value: self.clone(), target_type: "vec", source: None }), |
| 159 | + //} |
168 | 160 |
|
169 | 161 | pub fn as_json_value(&self) -> Result<serde_json::Value> {
|
170 | 162 | serde_json::from_str::<serde_json::Value>(&self.0)
|
|
0 commit comments