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

#10 in #asmjs

Download history 23806/week @ 2024-07-22 22349/week @ 2024-07-29 23235/week @ 2024-08-05 18521/week @ 2024-08-12 21383/week @ 2024-08-19 20718/week @ 2024-08-26 20212/week @ 2024-09-02 19533/week @ 2024-09-09 20290/week @ 2024-09-16 22857/week @ 2024-09-23 21334/week @ 2024-09-30 23172/week @ 2024-10-07 20796/week @ 2024-10-14 22467/week @ 2024-10-21 19804/week @ 2024-10-28 22201/week @ 2024-11-04

86,042 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.3–1MB
~21K SLoC