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 17465/week @ 2024-11-19 16550/week @ 2024-11-26 19426/week @ 2024-12-03 19220/week @ 2024-12-10 18424/week @ 2024-12-17 9496/week @ 2024-12-24 12218/week @ 2024-12-31 16830/week @ 2025-01-07 18244/week @ 2025-01-14 16820/week @ 2025-01-21 18950/week @ 2025-01-28 23398/week @ 2025-02-04 19008/week @ 2025-02-11 18553/week @ 2025-02-18 20334/week @ 2025-02-25 16064/week @ 2025-03-04

77,995 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–0.9MB
~20K SLoC