Skip to content

Commit

Permalink
review point:
Browse files Browse the repository at this point in the history
  • Loading branch information
pront committed Jan 29, 2025
1 parent 4d23a53 commit cb2a420
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/stdlib/downcase.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
use crate::compiler::prelude::*;

fn downcase(value: &Value) -> Resolved {
Ok(value.try_bytes_utf8_lossy()?.to_lowercase().into())
}

#[derive(Clone, Copy, Debug)]
pub struct Downcase;

Expand Down Expand Up @@ -44,7 +48,7 @@ struct DowncaseFn {
impl FunctionExpression for DowncaseFn {
fn resolve(&self, ctx: &mut Context) -> Resolved {
let value = self.value.resolve(ctx)?;
Ok(value.try_bytes_utf8_lossy()?.to_lowercase().into())
downcase(&value)
}

fn type_def(&self, _: &state::TypeState) -> TypeDef {
Expand Down
6 changes: 5 additions & 1 deletion src/stdlib/upcase.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
use crate::compiler::prelude::*;

fn upcase(value: &Value) -> Resolved {
Ok(value.try_bytes_utf8_lossy()?.to_uppercase().into())
}

#[derive(Clone, Copy, Debug)]
pub struct Upcase;

Expand Down Expand Up @@ -44,7 +48,7 @@ struct UpcaseFn {
impl FunctionExpression for UpcaseFn {
fn resolve(&self, ctx: &mut Context) -> Resolved {
let value = self.value.resolve(ctx)?;
Ok(value.try_bytes_utf8_lossy()?.to_uppercase().into())
upcase(&value)
}

fn type_def(&self, _: &TypeState) -> TypeDef {
Expand Down

0 comments on commit cb2a420

Please sign in to comment.