feat: 添加字符串工具函数(split, trim, substring, replace, contains, upper, lower, starts_with, ends_with)及相关测试用例
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
mod core;
|
||||
mod io;
|
||||
mod os;
|
||||
mod string;
|
||||
|
||||
use crate::interpreter::{Env, Value};
|
||||
use std::cell::RefCell;
|
||||
@@ -34,4 +35,15 @@ pub fn register_all(env: &Rc<RefCell<Env>>) {
|
||||
e.define("typeof".into(), Value::NativeFunction(core::typeof_fn), true);
|
||||
e.define("push".into(), Value::NativeFunction(core::push), true);
|
||||
e.define("pop".into(), Value::NativeFunction(core::pop), true);
|
||||
|
||||
// string — split, trim, substring, replace, contains, upper, lower, starts_with, ends_with
|
||||
e.define("split".into(), Value::NativeFunction(string::split), true);
|
||||
e.define("trim".into(), Value::NativeFunction(string::trim), true);
|
||||
e.define("substring".into(), Value::NativeFunction(string::substring), true);
|
||||
e.define("replace".into(), Value::NativeFunction(string::replace), true);
|
||||
e.define("contains".into(), Value::NativeFunction(string::contains), true);
|
||||
e.define("upper".into(), Value::NativeFunction(string::upper), true);
|
||||
e.define("lower".into(), Value::NativeFunction(string::lower), true);
|
||||
e.define("starts_with".into(), Value::NativeFunction(string::starts_with), true);
|
||||
e.define("ends_with".into(), Value::NativeFunction(string::ends_with), true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user