Split and join
(
mc: &'gc Mutation<'gc>,
receiver: Value<'gc>,
args: Vec<Value<'gc>>,
)
| 259 | |
| 260 | // Split and join |
| 261 | fn split<'gc>( |
| 262 | mc: &'gc Mutation<'gc>, |
| 263 | receiver: Value<'gc>, |
| 264 | args: Vec<Value<'gc>>, |
| 265 | ) -> Result<Value<'gc>, VmError> { |
| 266 | let delimiter = string_arg!(&args, 0, "split")?.to_str().unwrap(); |
| 267 | |
| 268 | let s = receiver.as_string_value()?; |
| 269 | let parts = s |
| 270 | .as_str() |
| 271 | .split(delimiter) |
| 272 | .map(|part| Value::IoString(Gc::new(mc, part.to_string()))) |
| 273 | .collect(); |
| 274 | |
| 275 | // Convert to array |
| 276 | Ok(Value::array(mc, parts)) |
| 277 | } |
| 278 | |
| 279 | fn join<'gc>( |
| 280 | mc: &'gc Mutation<'gc>, |
nothing calls this directly
no test coverage detected