Proposed Documentation Improvements (#2883)

* Proposed Documentation Improvements

#### Retrieved from https://yew.rs/docs/concepts/wasm-bindgen#jsvalue on 9/24/2022
`JsCast` is nicely structured so far, although I thought this section was worded strangely.
> The `dyn_into` method will consume `self`, as per convention for into methods in Rust, __and the type returned is `Result<T, Self>` this means if the casting fails then the value in `Err` is so you can try again or do something else with the original type.__

I believe this edit conveys the original idea, but makes more sense to the reader:

> The
[`dyn_into`](https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen/trait.JsCast.html#method.dyn_into)
method will consume `self`, as per convention for into methods in Rust, and the type returned is
`Result<T, Self>`. This means if the casting fails then the `Self` value in `Err` is preserved. You could try again
or do something else with the original type.

* Update website/versioned_docs/version-0.19.0/concepts/wasm-bindgen/introduction.mdx

Co-authored-by: Kaede Hoshikawa <futursolo@users.noreply.github.com>

* update latest docs

Co-authored-by: Muhammad Hamza <muhammadhamza1311@gmail.com>
Co-authored-by: Kaede Hoshikawa <futursolo@users.noreply.github.com>
This commit is contained in:
David M. Golembiowski 2022-11-06 08:42:46 -05:00 committed by GitHub
parent 81be10870a
commit 1f49353361
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -162,7 +162,7 @@ method is a checked cast that returns an `Option<&T>` which means the original t
can be used again if the cast failed and thus returned `None`. The can be used again if the cast failed and thus returned `None`. The
[`dyn_into`](https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen/trait.JsCast.html#method.dyn_into) [`dyn_into`](https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen/trait.JsCast.html#method.dyn_into)
method will consume `self`, as per convention for into methods in Rust, and the type returned is method will consume `self`, as per convention for into methods in Rust, and the type returned is
`Result<T, Self>` this means if the casting fails then the value in `Err` is so you can try again `Result<T, Self>`. If the casting fails, the original `Self` value is returned in `Err`. You can try again
or do something else with the original type. or do something else with the original type.
_[`JsCast` documentation](https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen/trait.JsCast.html)._ _[`JsCast` documentation](https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen/trait.JsCast.html)._

View File

@ -164,7 +164,7 @@ method is a checked cast that returns an `Option<&T>` which means the original t
can be used again if the cast failed and thus returned `None`. The can be used again if the cast failed and thus returned `None`. The
[`dyn_into`](https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen/trait.JsCast.html#method.dyn_into) [`dyn_into`](https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen/trait.JsCast.html#method.dyn_into)
method will consume `self`, as per convention for into methods in Rust, and the type returned is method will consume `self`, as per convention for into methods in Rust, and the type returned is
`Result<T, Self>` this means if the casting fails then the value in `Err` is so you can try again `Result<T, Self>`. If the casting fails, the original `Self` value is returned in `Err`. You can try again
or do something else with the original type. or do something else with the original type.
_[`JsCast` documentation](https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen/trait.JsCast.html)._ _[`JsCast` documentation](https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen/trait.JsCast.html)._