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 27655/week @ 2023-12-21 30217/week @ 2023-12-28 30304/week @ 2024-01-04 31060/week @ 2024-01-11 45009/week @ 2024-01-18 35830/week @ 2024-01-25 39557/week @ 2024-02-01 36840/week @ 2024-02-08 26930/week @ 2024-02-15 30270/week @ 2024-02-22 31021/week @ 2024-02-29 31620/week @ 2024-03-07 32351/week @ 2024-03-14 29099/week @ 2024-03-21 43247/week @ 2024-03-28 26518/week @ 2024-04-04

136,370 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