Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions crates/monty/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ speedate = "0.17.0"
itertools = "0.14.0"
jiter = { version = "0.15.0", features = ["num-bigint"] }
monty-macros = { workspace = true }
# Portable monotonic clock: a drop-in for `std::time::Instant` that re-exports
# std unchanged on native and WASI, and is backed by `performance.now()` on
# `wasm32-unknown-unknown` (where `std::time::Instant::now()` panics). Keeps the
# `max_duration` resource limit usable when `monty` is embedded directly in a
# browser wasm module rather than run over WASI.
web-time = "1.1"

[features]
# ref-count-return changes behavior to return information on reference counts to check they're correct
Expand Down
15 changes: 9 additions & 6 deletions crates/monty/src/resource.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
use std::{
cell::Cell,
error::Error,
fmt,
time::{Duration, Instant},
};
use std::{cell::Cell, error::Error, fmt, time::Duration};

// `web_time::Instant` is `std::time::Instant` on native and WASI targets, and a
// `performance.now()`-backed clock on `wasm32-unknown-unknown`, where the std
// `Instant::now()` panics ("time not implemented on this platform"). This keeps
// the `max_duration` time limit working when `monty` is embedded directly in a
// browser wasm module. Time behavior on all currently-supported targets is
// unchanged (it re-exports std verbatim there).
use web_time::Instant;

use crate::{
ExcType, MontyException,
Expand Down
Loading