Remove duplicate SQL string::substr() function

This commit is contained in:
Tobie Morgan Hitchcock 2022-05-02 23:22:22 +01:00
parent 0cbcb3b374
commit 01ab9375a3
3 changed files with 0 additions and 10 deletions

View file

@ -127,7 +127,6 @@ pub async fn run(ctx: &Runtime, name: &str, args: Vec<Value>) -> Result<Value, E
"string::slug" => args::check(ctx, name, args, Args::OneTwo, string::slug), "string::slug" => args::check(ctx, name, args, Args::OneTwo, string::slug),
"string::split" => args::check(ctx, name, args, Args::Two, string::split), "string::split" => args::check(ctx, name, args, Args::Two, string::split),
"string::startsWith" => args::check(ctx, name, args, Args::Two, string::starts_with), "string::startsWith" => args::check(ctx, name, args, Args::Two, string::starts_with),
"string::substr" => args::check(ctx, name, args, Args::Three, string::substr),
"string::trim" => args::check(ctx, name, args, Args::One, string::trim), "string::trim" => args::check(ctx, name, args, Args::One, string::trim),
"string::uppercase" => args::check(ctx, name, args, Args::One, string::uppercase), "string::uppercase" => args::check(ctx, name, args, Args::One, string::uppercase),
"string::words" => args::check(ctx, name, args, Args::One, string::words), "string::words" => args::check(ctx, name, args, Args::One, string::words),

View file

@ -72,14 +72,6 @@ pub fn starts_with(_: &Runtime, mut args: Vec<Value>) -> Result<Value, Error> {
Ok(val.starts_with(&chr).into()) Ok(val.starts_with(&chr).into())
} }
pub fn substr(_: &Runtime, mut args: Vec<Value>) -> Result<Value, Error> {
let val = args.remove(0).as_strand();
let beg = args.remove(0).as_int() as usize;
let lim = args.remove(0).as_int() as usize;
let val = val.value.chars().skip(beg).take(lim).collect::<String>();
Ok(val.into())
}
pub fn trim(_: &Runtime, mut args: Vec<Value>) -> Result<Value, Error> { pub fn trim(_: &Runtime, mut args: Vec<Value>) -> Result<Value, Error> {
Ok(args.remove(0).as_strand().value.trim().into()) Ok(args.remove(0).as_strand().value.trim().into())
} }

View file

@ -377,7 +377,6 @@ fn function_string(i: &str) -> IResult<&str, &str> {
tag("string::slug"), tag("string::slug"),
tag("string::split"), tag("string::split"),
tag("string::startsWith"), tag("string::startsWith"),
tag("string::substr"),
tag("string::trim"), tag("string::trim"),
tag("string::uppercase"), tag("string::uppercase"),
tag("string::words"), tag("string::words"),