alef 0.114.0

Opinionated polyglot binding generator for Rust libraries
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/// Convert the error a core call returned into the typed Ruby exception of its family. An error
/// of a type with no converter becomes a `RuntimeError` with the message.
#[allow(dead_code)]
fn alef_magnus_err<E: std::fmt::Display + 'static>(e: E) -> magnus::Error {
    let message = e.to_string();
    #[allow(unused_variables)]
    let any: Box<dyn std::any::Any> = Box::new(e);
{% for arm in arms %}    let any = match any.downcast::<{{ arm.rust_path }}>() {
        Ok(typed) => return {{ arm.fn_name }}(*typed),
        Err(any) => any,
    };
{% endfor %}    let _ = any;
    magnus::Error::new(unsafe { magnus::Ruby::get_unchecked() }.exception_runtime_error(), message)
}