(chars: &[char], pos: &mut usize)
| 166 | } |
| 167 | |
| 168 | fn parse_number(chars: &[char], pos: &mut usize) -> Result<Value, SqlError> { |
| 169 | let start = *pos; |
| 170 | if *pos < chars.len() && chars[*pos] == '-' { |
| 171 | *pos += 1; |
| 172 | } |
| 173 | while *pos < chars.len() && chars[*pos].is_ascii_digit() { |
| 174 | *pos += 1; |
| 175 | } |
| 176 | let is_float = *pos < chars.len() && chars[*pos] == '.'; |
| 177 | if is_float { |
| 178 | *pos += 1; // consume '.' |
| 179 | while *pos < chars.len() && chars[*pos].is_ascii_digit() { |
| 180 | *pos += 1; |
| 181 | } |
| 182 | } |
| 183 | let raw: String = chars[start..*pos].iter().collect(); |
| 184 | if is_float { |
| 185 | raw.parse::<f64>() |
| 186 | .map(Value::Float) |
| 187 | .map_err(|_| SqlError::Parse { |
| 188 | detail: format!("invalid float: {raw}"), |
| 189 | }) |
| 190 | } else { |
| 191 | raw.parse::<i64>() |
| 192 | .map(Value::Integer) |
| 193 | .map_err(|_| SqlError::Parse { |
| 194 | detail: format!("invalid integer: {raw}"), |
| 195 | }) |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | fn parse_array(chars: &[char], pos: &mut usize) -> Result<Vec<Value>, SqlError> { |
| 200 | // Expect '[' |
no test coverage detected