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

#11 in #asmjs

Download history 36986/week @ 2024-04-02 28310/week @ 2024-04-09 29697/week @ 2024-04-16 27966/week @ 2024-04-23 25627/week @ 2024-04-30 22787/week @ 2024-05-07 35432/week @ 2024-05-14 39207/week @ 2024-05-21 31310/week @ 2024-05-28 25548/week @ 2024-06-04 23299/week @ 2024-06-11 24528/week @ 2024-06-18 20490/week @ 2024-06-25 19083/week @ 2024-07-02 21314/week @ 2024-07-09 18793/week @ 2024-07-16

83,769 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

~1.5MB
~40K SLoC