1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use crate::{ContextError, Module};
use std::num::ParseFloatError;
fn parse(s: &str) -> Result<f64, ParseFloatError> {
Ok(str::parse::<f64>(s)?)
}
fn to_integer(value: f64) -> i64 {
value as i64
}
crate::__internal_impl_any!(ParseFloatError);
pub fn module() -> Result<Module, ContextError> {
let mut module = Module::with_crate_item("std", &["float"]);
module.ty::<ParseFloatError>()?;
module.function(&["parse"], parse)?;
module.inst_fn("max", f64::max)?;
module.inst_fn("min", f64::min)?;
module.inst_fn("abs", f64::abs)?;
module.inst_fn("powf", f64::powf)?;
module.inst_fn("powi", f64::powi)?;
module.inst_fn("to_integer", to_integer)?;
Ok(module)
}