From d72334c246665b49eec06e7e6237798693b7d90c Mon Sep 17 00:00:00 2001 From: Quest Date: Fri, 12 Apr 2019 23:04:40 +0200 Subject: [PATCH] Rename builtin upcase,downcase -> to_uppercase, to_lowercase. --- README.md | 4 ++-- src/error/mod.rs | 2 +- src/function/builtin.rs | 4 ++-- tests/integration.rs | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 46a113f..7448d3d 100644 --- a/README.md +++ b/README.md @@ -214,12 +214,12 @@ This crate offers a set of builtin functions. |------------|-----------------|-------------| | min | >= 1 | Returns the minimum of the arguments | | max | >= 1 | Returns the maximum of the arguments | -| downcase | 1 | Returns lower-case version of string | +| to_lowercase | 1 | Returns lower-case version of string | | len | 1 | Return the character length of string argument | | regex_matches | 2 | Returns true if first string argument matches regex in second | | regex_replace | 3 | Returns string with matches replaced by third argument | | trim | 1 | Strips whitespace from start and end of string | -| upcase | 1 | Returns upper-case version of string | +| to_uppercase | 1 | Returns upper-case version of string | The `min` and `max` functions can deal with a mixture of integer and floating point arguments. They return the result as the type it was passed into the function. The regex functions require diff --git a/src/error/mod.rs b/src/error/mod.rs index 729f192..47d5bb1 100644 --- a/src/error/mod.rs +++ b/src/error/mod.rs @@ -340,7 +340,7 @@ pub fn expect_number(actual: &Value) -> EvalexprResult<()> { } } -/// Returns Ok(()) if the given value is a string or a numeric +/// Returns `Ok(())` if the given value is a string or a numeric pub fn expect_number_or_string(actual: &Value) -> EvalexprResult<()> { match actual { Value::String(_) | Value::Float(_) | Value::Int(_) => Ok(()), diff --git a/src/function/builtin.rs b/src/function/builtin.rs index e0d7a7d..38ccb56 100644 --- a/src/function/builtin.rs +++ b/src/function/builtin.rs @@ -60,7 +60,7 @@ pub fn builtin_function(identifier: &str) -> Option { // string functions - "downcase" => Some(Function::new( + "to_lowercase" => Some(Function::new( Some(1), Box::new(|arguments| { let subject = expect_string(&arguments[0])?; @@ -106,7 +106,7 @@ pub fn builtin_function(identifier: &str) -> Option { Ok(Value::from(subject.trim())) }), )), - "upcase" => Some(Function::new( + "to_uppercase" => Some(Function::new( Some(1), Box::new(|arguments| { let subject = expect_string(&arguments[0])?; diff --git a/tests/integration.rs b/tests/integration.rs index 13f0793..6d308b7 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -288,7 +288,7 @@ fn test_builtin_functions() { Ok(Value::Float(4.0)) ); assert_eq!( - eval("downcase(\"FOOBAR\")"), + eval("to_lowercase(\"FOOBAR\")"), Ok(Value::from("foobar")) ); assert_eq!( @@ -300,7 +300,7 @@ fn test_builtin_functions() { Ok(Value::from("foo bar")) ); assert_eq!( - eval("upcase(\"foobar\")"), + eval("to_uppercase(\"foobar\")"), Ok(Value::from("FOOBAR")) ); }