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

#269 in Caching

Download history 14/week @ 2024-01-05 26/week @ 2024-01-12 19/week @ 2024-01-19 43/week @ 2024-01-26 40/week @ 2024-02-02 33/week @ 2024-02-09 27/week @ 2024-02-16 69/week @ 2024-02-23 22/week @ 2024-03-01 63/week @ 2024-03-08 62/week @ 2024-03-15 55/week @ 2024-03-22 38/week @ 2024-03-29 32/week @ 2024-04-05 23/week @ 2024-04-12 36/week @ 2024-04-19

144 downloads per month
Used in 2 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.8–1.4MB
~30K SLoC