Skip to content

Commit

Permalink
Add NUMBER builtin function
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiretza committed Apr 26, 2024
1 parent 6b4eb16 commit c2bde7a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions fluent-bundle/src/builtins.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use crate::{FluentArgs, FluentValue};

#[allow(non_snake_case)]
pub fn NUMBER<'a>(positional: &[FluentValue<'a>], named: &FluentArgs) -> FluentValue<'a> {
let Some(FluentValue::Number(n)) = positional.first() else {
return FluentValue::Error;
};

let mut n = n.clone();
n.options.merge(named);
println!("{named:?} => {n:?}");

FluentValue::Number(n)
}
1 change: 1 addition & 0 deletions fluent-bundle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
//! the `fluent-bundle` crate directly, while the ecosystem
//! matures and higher level APIs are being developed.
mod args;
pub mod builtins;
pub mod bundle;
pub mod concurrent;
mod entry;
Expand Down

0 comments on commit c2bde7a

Please sign in to comment.