#web #asmjs #webasm #javascript

macro stdweb-derive

Derive macros for the stdweb crate

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

#20 in #asmjs

Download history 46461/week @ 2023-02-03 45887/week @ 2023-02-10 46259/week @ 2023-02-17 40226/week @ 2023-02-24 62581/week @ 2023-03-03 48890/week @ 2023-03-10 45278/week @ 2023-03-17 50071/week @ 2023-03-24 49305/week @ 2023-03-31 48455/week @ 2023-04-07 46785/week @ 2023-04-14 43257/week @ 2023-04-21 35276/week @ 2023-04-28 36877/week @ 2023-05-05 43122/week @ 2023-05-12 34079/week @ 2023-05-19

156,232 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–1.5MB
~35K SLoC