5 releases

Uses old Rust 2015

0.5.3 Oct 10, 2019
0.5.2 Sep 29, 2019
0.5.1 Oct 24, 2018
0.5.0 Aug 27, 2018
0.4.0 Feb 21, 2018

#12 in #asmjs

Download history 19493/week @ 2024-12-02 18975/week @ 2024-12-09 19836/week @ 2024-12-16 9603/week @ 2024-12-23 11118/week @ 2024-12-30 17059/week @ 2025-01-06 18782/week @ 2025-01-13 16307/week @ 2025-01-20 18260/week @ 2025-01-27 22912/week @ 2025-02-03 20249/week @ 2025-02-10 17709/week @ 2025-02-17 20949/week @ 2025-02-24 18769/week @ 2025-03-03 20667/week @ 2025-03-10 21762/week @ 2025-03-17

82,905 downloads per month
Used in fewer than 9 crates

MIT/Apache

17KB
289 lines

Derive macros for the stdweb crate

This crate currently defines a derive macro for stdweb which allows you to define custom reference types outside of stdweb.

For example:

#[derive(Clone, Debug, PartialEq, Eq, ReferenceType)]
#[reference(instance_of = "Error")]
pub struct Error( Reference );

#[derive(Clone, Debug, PartialEq, Eq, ReferenceType)]
#[reference(instance_of = "TypeError")]
#[reference(subclass_of(Error))]
pub struct TypeError( Reference );

And then you can do:

// You can use `try_into` to cast a `Value` to your type.
let error: TypeError = js!( return new TypeError(); ).try_into().unwrap();

// You can also pass your type freely into the `js!` macro:
js!( console.log( @{error} ); );

Dependencies

~2MB
~43K SLoC