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 46508/week @ 2023-12-04 36010/week @ 2023-12-11 44129/week @ 2023-12-18 17335/week @ 2023-12-25 32220/week @ 2024-01-01 31598/week @ 2024-01-08 39796/week @ 2024-01-15 39283/week @ 2024-01-22 36083/week @ 2024-01-29 39447/week @ 2024-02-05 34253/week @ 2024-02-12 25920/week @ 2024-02-19 33198/week @ 2024-02-26 27526/week @ 2024-03-04 31991/week @ 2024-03-11 32821/week @ 2024-03-18

127,467 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

~0.4–1MB
~24K SLoC