4 releases (2 breaking)

0.3.1 Jul 5, 2019
0.2.1 Jun 24, 2019
0.2.0 Jun 24, 2019
0.1.0 Jun 22, 2019

#315 in Caching

Download history 93/week @ 2024-07-22 77/week @ 2024-07-29 46/week @ 2024-08-05 125/week @ 2024-08-12 53/week @ 2024-08-19 85/week @ 2024-08-26 65/week @ 2024-09-02 29/week @ 2024-09-09 76/week @ 2024-09-16 129/week @ 2024-09-23 269/week @ 2024-09-30 267/week @ 2024-10-07 180/week @ 2024-10-14 177/week @ 2024-10-21 82/week @ 2024-10-28 46/week @ 2024-11-04

493 downloads per month
Used in 3 crates

MIT license

13KB
146 lines

A macro for interning JavaScript primitives.

Stores one copy of each distinct JavaScript primitive. For example, js_intern!("string") evaluates to a &JsValue but uses only one heap allocation and a one-time translation from the utf-8 Rust string to the utf-16 JavaScript string the first time the expression is evaluated. Furthermore, values are de-duplicated across the program. So, any time js_intern!(1.0) is used in the program, the same instance of the JavaScript number is used.

Supported types

  • &'static str Eg: js_intern!("str")
  • f64, f32 u8, u16, u32, i8, i16, i32 Eg: js_intern(1.0)
  • bool Eg: js_intern(true)

Related

If you like this, you may like these other crates by Zac Burns (That3Percent)

  • js-object A macro for creating JavaScript objects
  • soa-vec A struct of arrays layout with a Vec of tuple API
  • second-stack A Rust memory allocator for large slices that don't escape the stack.

Dependencies

~0.7–1.4MB
~28K SLoC