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 43247/week @ 2024-03-28 31466/week @ 2024-04-04 28533/week @ 2024-04-11 31153/week @ 2024-04-18 25587/week @ 2024-04-25 24346/week @ 2024-05-02 26506/week @ 2024-05-09 41207/week @ 2024-05-16 34331/week @ 2024-05-23 28018/week @ 2024-05-30 24545/week @ 2024-06-06 24076/week @ 2024-06-13 23071/week @ 2024-06-20 19313/week @ 2024-06-27 20861/week @ 2024-07-04 16877/week @ 2024-07-11

84,565 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.3–1.7MB
~40K SLoC