Macro janetrs::jtry

source ·
macro_rules! jtry {
    ($e:expr) => { ... };
}
Available on crate feature std only.
Expand description

Macro that tries to run a expression, and if it panics in the Rust side, it tries to recover from that and pass the Rust panic string to a Janet Panic.

This uses the catch_unwind function, and therefore have the same guarantees as it.

§Examples

use janetrs::jtry;

let arr = [10; 5];
let val_index_2 = jtry!(arr[2]); // Not going to panic
let val_index_20 = jtry!(arr[20]); // Index out bounds