From dc10474e56bb1c46b260688558ac23ac4f412b7a Mon Sep 17 00:00:00 2001 From: Liam Murphy Date: Thu, 10 Aug 2023 22:18:58 +1000 Subject: [PATCH] Update the guide --- guide/src/SUMMARY.md | 2 +- .../{boxed-jsvalue-slice.md => boxed-slices.md} | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) rename guide/src/reference/types/{boxed-jsvalue-slice.md => boxed-slices.md} (58%) diff --git a/guide/src/SUMMARY.md b/guide/src/SUMMARY.md index b6e4319d340..b0e32f8947d 100644 --- a/guide/src/SUMMARY.md +++ b/guide/src/SUMMARY.md @@ -50,7 +50,7 @@ - [Imported JavaScript Types](./reference/types/imported-js-types.md) - [Exported Rust Types](./reference/types/exported-rust-types.md) - [`JsValue`](./reference/types/jsvalue.md) - - [`Box<[JsValue]>`](./reference/types/boxed-jsvalue-slice.md) + - [`Box<[T]>` and `Vec`](./reference/types/boxed-slices.md) - [`*const T` and `*mut T`](./reference/types/pointers.md) - [Numbers](./reference/types/numbers.md) - [`bool`](./reference/types/bool.md) diff --git a/guide/src/reference/types/boxed-jsvalue-slice.md b/guide/src/reference/types/boxed-slices.md similarity index 58% rename from guide/src/reference/types/boxed-jsvalue-slice.md rename to guide/src/reference/types/boxed-slices.md index 8060d194a7c..ed299462292 100644 --- a/guide/src/reference/types/boxed-jsvalue-slice.md +++ b/guide/src/reference/types/boxed-slices.md @@ -1,10 +1,19 @@ -# `Box<[JsValue]>` +# `Box<[T]>` and `Vec` | `T` parameter | `&T` parameter | `&mut T` parameter | `T` return value | `Option` parameter | `Option` return value | JavaScript representation | |:---:|:---:|:---:|:---:|:---:|:---:|:---:| | Yes | No | No | Yes | Yes | Yes | A JavaScript `Array` object | -Boxed slices of imported JS types and exported Rust types are also supported. `Vec` is supported wherever `Box<[T]>` is. +You can pass boxed slices and `Vec`s of several different types to and from JS: + +- `JsValue`s. +- Imported JavaScript types. +- Exported Rust types. +- `String`s. + +[You can also pass boxed slices of numbers to JS](boxed-number-slices.html), +except that they're converted to typed arrays (`Uint8Array`, `Int32Array`, etc.) +instead of regular arrays. ## Example Rust Usage