Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bytecodealliance
GitHub Repository: bytecodealliance/wasmtime
Path: blob/main/crates/wizer/tests/regex-test/src/lib.rs
2460 views
1
use regex::Regex;
2
use std::sync::LazyLock;
3
4
/// A regex that matches numbers that start with "1".
5
static REGEX: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"^1\d*$").unwrap());
6
7
#[unsafe(export_name = "wizer-initialize")]
8
pub fn init() {
9
LazyLock::force(&REGEX);
10
}
11
12
#[unsafe(no_mangle)]
13
pub fn run(n: i32) -> i32 {
14
let s = format!("{n}");
15
if REGEX.is_match(&s) { 42 } else { 0 }
16
}
17
18