From fc4da0b38e585b06b499d6b2baa5b842c3ab88ed Mon Sep 17 00:00:00 2001 From: "K.J. Valencik" Date: Fri, 3 Jun 2022 09:09:25 -0400 Subject: [PATCH 1/2] Ignore doc tests for some example macro output --- crates/neon/src/sys/bindings/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/neon/src/sys/bindings/mod.rs b/crates/neon/src/sys/bindings/mod.rs index ea19db265..10bd2f015 100644 --- a/crates/neon/src/sys/bindings/mod.rs +++ b/crates/neon/src/sys/bindings/mod.rs @@ -37,7 +37,7 @@ macro_rules! napi_name { /// /// Sample input: /// -/// ``` +/// ```ignore /// extern "C" { /// fn get_undefined(env: Env, result: *mut Value) -> Status; /// /* Additional functions may be included */ @@ -46,7 +46,7 @@ macro_rules! napi_name { /// /// Generated output: /// -/// ``` +/// ```ignore /// // Each field is a pointer to a N-API function /// struct Napi { /// get_undefined: unsafe extern "C" fn(env: Env, result: *mut Value) -> Status, From 8f5cbb6cef3d9655195a7dcfb54c170feb570613 Mon Sep 17 00:00:00 2001 From: "K.J. Valencik" Date: Wed, 8 Jun 2022 14:56:57 -0400 Subject: [PATCH 2/2] neon: Remove JsResultExt JsResultExt is redundant with ResultExt. They are identical traits except for an additional `V: Value` bound in `JsResultExt`. --- crates/neon/src/handle/mod.rs | 4 ++-- crates/neon/src/prelude.rs | 2 +- crates/neon/src/result/mod.rs | 8 +------- crates/neon/src/types/date.rs | 4 ++-- crates/neon/src/types/mod.rs | 4 ++-- 5 files changed, 8 insertions(+), 14 deletions(-) diff --git a/crates/neon/src/handle/mod.rs b/crates/neon/src/handle/mod.rs index 35dbcfa65..0d61fded0 100644 --- a/crates/neon/src/handle/mod.rs +++ b/crates/neon/src/handle/mod.rs @@ -63,7 +63,7 @@ pub use self::root::Root; use crate::{ context::{internal::Env, Context}, handle::internal::{SuperType, TransparentNoCopyWrapper}, - result::{JsResult, JsResultExt}, + result::{JsResult, ResultExt}, sys::{self, raw}, types::Value, }; @@ -138,7 +138,7 @@ impl Error for DowncastError {} /// The result of a call to [`Handle::downcast()`](Handle::downcast). pub type DowncastResult<'a, F, T> = Result, DowncastError>; -impl<'a, F: Value, T: Value> JsResultExt<'a, T> for DowncastResult<'a, F, T> { +impl<'a, F: Value, T: Value> ResultExt> for DowncastResult<'a, F, T> { fn or_throw<'b, C: Context<'b>>(self, cx: &mut C) -> JsResult<'a, T> { match self { Ok(v) => Ok(v), diff --git a/crates/neon/src/prelude.rs b/crates/neon/src/prelude.rs index 3acc9f4af..e0494554b 100644 --- a/crates/neon/src/prelude.rs +++ b/crates/neon/src/prelude.rs @@ -8,7 +8,7 @@ pub use crate::{ }, handle::{Handle, Root}, object::Object, - result::{JsResult, JsResultExt, NeonResult, ResultExt as NeonResultExt}, + result::{JsResult, NeonResult, ResultExt as NeonResultExt}, types::{ boxed::{Finalize, JsBox}, JsArray, JsArrayBuffer, JsBoolean, JsBuffer, JsError, JsFunction, JsNull, JsNumber, diff --git a/crates/neon/src/result/mod.rs b/crates/neon/src/result/mod.rs index 36dceb967..021e21315 100644 --- a/crates/neon/src/result/mod.rs +++ b/crates/neon/src/result/mod.rs @@ -38,7 +38,7 @@ use std::{ marker::PhantomData, }; -use crate::{context::Context, handle::Handle, types::Value}; +use crate::{context::Context, handle::Handle}; /// A [unit type][unit] indicating that the JavaScript thread is throwing an exception. /// @@ -69,12 +69,6 @@ pub type NeonResult = Result; /// Shorthand for a [`NeonResult`](NeonResult) that produces JavaScript values. pub type JsResult<'b, T> = NeonResult>; -/// Extension trait for converting Rust [`Result`](std::result::Result) values -/// into [`JsResult`](JsResult) values by throwing JavaScript exceptions. -pub trait JsResultExt<'a, V: Value> { - fn or_throw<'b, C: Context<'b>>(self, cx: &mut C) -> JsResult<'a, V>; -} - /// Extension trait for converting Rust [`Result`](std::result::Result) values /// into [`NeonResult`](NeonResult) values by throwing JavaScript exceptions. pub trait ResultExt { diff --git a/crates/neon/src/types/date.rs b/crates/neon/src/types/date.rs index efcce355f..4095c8b54 100644 --- a/crates/neon/src/types/date.rs +++ b/crates/neon/src/types/date.rs @@ -9,7 +9,7 @@ use crate::{ context::{internal::Env, Context}, handle::{internal::TransparentNoCopyWrapper, Handle, Managed}, object::Object, - result::{JsResult, JsResultExt}, + result::{JsResult, ResultExt}, sys::{self, raw}, }; @@ -75,7 +75,7 @@ impl DateErrorKind { } } -impl<'a, T: Value> JsResultExt<'a, T> for Result, DateError> { +impl<'a, T: Value> ResultExt> for Result, DateError> { /// Creates an `Error` on error fn or_throw<'b, C: Context<'b>>(self, cx: &mut C) -> JsResult<'a, T> { self.or_else(|e| cx.throw_range_error(e.0.as_str())) diff --git a/crates/neon/src/types/mod.rs b/crates/neon/src/types/mod.rs index f6ee3188a..34f2b93ff 100644 --- a/crates/neon/src/types/mod.rs +++ b/crates/neon/src/types/mod.rs @@ -98,7 +98,7 @@ use crate::{ Handle, Managed, }, object::{Object, This}, - result::{JsResult, JsResultExt, NeonResult, Throw}, + result::{JsResult, NeonResult, ResultExt, Throw}, sys::{self, raw}, types::{ function::{CallOptions, ConstructOptions}, @@ -388,7 +388,7 @@ impl fmt::Display for StringOverflow { /// The result of constructing a new `JsString`. pub type StringResult<'a> = Result, StringOverflow>; -impl<'a> JsResultExt<'a, JsString> for StringResult<'a> { +impl<'a> ResultExt> for StringResult<'a> { fn or_throw<'b, C: Context<'b>>(self, cx: &mut C) -> JsResult<'a, JsString> { match self { Ok(v) => Ok(v),