Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - API to construct a NativeFunction from a native async function #2542

Closed
wants to merge 13 commits into from
Prev Previous commit
Fix docs
  • Loading branch information
jedel1043 committed Feb 24, 2023
commit a6aa8572f2a08f73a4045fbd0941ccc453b0b958
15 changes: 14 additions & 1 deletion boa_engine/src/native_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ impl NativeFunction {
/// Consider the next snippet:
///
/// ```compile_fail
/// # use boa_engine::{
/// # JsValue,
/// # Context,
/// # JsResult,
/// # NativeFunction
/// # };
/// async fn test(
/// _this: &JsValue,
/// args: &[JsValue],
Expand All @@ -148,11 +154,18 @@ impl NativeFunction {
///
/// This code unfortunately fails to compile at the moment. This is because `rustc` currently
/// cannot determine that `args` can be dropped before the await point, which would trivially
/// make the future `'static`. Track [this issue] for more information on when this'll get fixed.
/// make the future `'static`. Track [this issue] for more information.
///
/// In the meantime, a manual desugaring of the async function does the trick:
///
/// ```
/// # use std::future::Future;
/// # use boa_engine::{
/// # JsValue,
/// # Context,
/// # JsResult,
/// # NativeFunction
/// # };
/// fn test(
/// _this: &JsValue,
/// args: &[JsValue],
Expand Down
2 changes: 1 addition & 1 deletion boa_interner/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ impl<'a, const N: usize> From<&'a [u16; N]> for JStrRef<'a> {
/// [`JSInternedStrRef::utf8`] returns an [`Option`], since not every `UTF-16` string is fully
/// representable as a `UTF-8` string (because of unpaired surrogates). However, every `UTF-8`
/// string is representable as a `UTF-16` string, so `JSInternedStrRef::utf8` returns a
/// [<code>&\[u16\]</code>][std::slice].
/// [<code>&\[u16\]</code>][core::slice].
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct JSInternedStrRef<'a, 'b> {
utf8: Option<&'a str>,
Expand Down