MCPcopy Index your code
hub / github.com/aiscriptdev/aiscript / replace

Function replace

aiscript-vm/src/builtins/string.rs:390–405  ·  view source on GitHub ↗
(
    mc: &'gc Mutation<'gc>,
    receiver: Value<'gc>,
    args: Vec<Value<'gc>>,
)

Source from the content-addressed store, hash-verified

388}
389
390fn replace<'gc>(
391 mc: &'gc Mutation<'gc>,
392 receiver: Value<'gc>,
393 args: Vec<Value<'gc>>,
394) -> Result<Value<'gc>, VmError> {
395 let from = string_arg!(&args, 0, "replace")?;
396 let to = string_arg!(&args, 1, "replace")?;
397
398 let result = receiver
399 .as_string()?
400 .to_str()
401 .unwrap()
402 .replace(from.to_str().unwrap(), to.to_str().unwrap());
403 // Ok(Value::String(mc.intern(result.as_bytes())))
404 Ok(Value::IoString(Gc::new(mc, result)))
405}

Callers 6

read_raw_scriptMethod · 0.85
dropMethod · 0.85
switchMethod · 0.85
generate_lambdaMethod · 0.85
generate_functionMethod · 0.85
import_moduleMethod · 0.85

Calls 2

to_strMethod · 0.80
as_stringMethod · 0.80

Tested by

no test coverage detected