grass/src/builtin/string.rs

22 lines
623 B
Rust
Raw Normal View History

use std::collections::BTreeMap;
2020-02-02 21:09:29 -05:00
use super::Builtin;
use crate::value::Value;
pub(crate) fn register(f: &mut BTreeMap<String, Builtin>) {
decl!(f "to-upper-case", |args, _| {
let s: &Value = arg!(args, 0, "string");
match s.eval() {
Value::Ident(i, q) => Some(Value::Ident(i.to_ascii_uppercase(), q)),
_ => todo!("")
}
});
decl!(f "to-lower-case", |args, _| {
let s: &Value = arg!(args, 0, "string");
match s.eval() {
Value::Ident(i, q) => Some(Value::Ident(i.to_ascii_lowercase(), q)),
_ => todo!("")
}
});
}