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

Put #[automatically_derived] on impls #44

Merged
merged 1 commit into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion tests/expand/borrow.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ struct Borrow<'a> {
raw: &'a str,
cow: Cow<'a, str>,
}
#[automatically_derived]
const _: () = {
extern crate serde as _serde;
use tsify_next::Tsify;
Expand All @@ -21,6 +20,7 @@ const _: () = {
#[wasm_bindgen(typescript_type = "Borrow")]
pub type JsType;
}
#[automatically_derived]
impl<'a> Tsify for Borrow<'a> {
type JsType = JsType;
const DECL: &'static str = "export interface Borrow {\n raw: string;\n cow: string;\n}";
Expand All @@ -32,18 +32,21 @@ const _: () = {
}
#[wasm_bindgen(typescript_custom_section)]
const TS_APPEND_CONTENT: &'static str = "export interface Borrow {\n raw: string;\n cow: string;\n}";
#[automatically_derived]
impl<'a> WasmDescribe for Borrow<'a> {
#[inline]
fn describe() {
<Self as Tsify>::JsType::describe()
}
}
#[automatically_derived]
impl<'a> WasmDescribeVector for Borrow<'a> {
#[inline]
fn describe_vector() {
<Self as Tsify>::JsType::describe_vector()
}
}
#[automatically_derived]
impl<'a> IntoWasmAbi for Borrow<'a>
where
Borrow<'a>: _serde::Serialize,
Expand Down Expand Up @@ -81,6 +84,7 @@ const _: () = {
}
}
}
#[automatically_derived]
impl<'a> OptionIntoWasmAbi for Borrow<'a>
where
Borrow<'a>: _serde::Serialize,
Expand All @@ -90,6 +94,7 @@ const _: () = {
<JsType as OptionIntoWasmAbi>::none()
}
}
#[automatically_derived]
impl<'a> From<Borrow<'a>> for JsValue
where
Borrow<'a>: _serde::Serialize,
Expand Down Expand Up @@ -126,6 +131,7 @@ const _: () = {
}
}
}
#[automatically_derived]
impl<'a> VectorIntoWasmAbi for Borrow<'a>
where
Borrow<'a>: _serde::Serialize,
Expand Down Expand Up @@ -167,6 +173,7 @@ const _: () = {
JsValue::vector_into_abi(values)
}
}
#[automatically_derived]
impl<'a> FromWasmAbi for Borrow<'a>
where
Self: _serde::de::DeserializeOwned,
Expand All @@ -181,6 +188,7 @@ const _: () = {
result.unwrap_throw()
}
}
#[automatically_derived]
impl<'a> OptionFromWasmAbi for Borrow<'a>
where
Self: _serde::de::DeserializeOwned,
Expand All @@ -191,12 +199,14 @@ const _: () = {
}
}
pub struct SelfOwner<T>(T);
#[automatically_derived]
impl<T> ::core::ops::Deref for SelfOwner<T> {
type Target = T;
fn deref(&self) -> &Self::Target {
&self.0
}
}
#[automatically_derived]
impl<'a> RefFromWasmAbi for Borrow<'a>
where
Self: _serde::de::DeserializeOwned,
Expand All @@ -211,6 +221,7 @@ const _: () = {
SelfOwner(result.unwrap_throw())
}
}
#[automatically_derived]
impl<'a> VectorFromWasmAbi for Borrow<'a>
where
Self: _serde::de::DeserializeOwned,
Expand Down
13 changes: 12 additions & 1 deletion tests/expand/generic_enum.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ pub enum GenericEnum<T, U> {
Seq(T, U),
Map { x: T, y: U },
}
#[automatically_derived]
const _: () = {
extern crate serde as _serde;
use tsify_next::Tsify;
Expand All @@ -22,6 +21,7 @@ const _: () = {
#[wasm_bindgen(typescript_type = "GenericEnum")]
pub type JsType;
}
#[automatically_derived]
impl<T, U> Tsify for GenericEnum<T, U> {
type JsType = JsType;
const DECL: &'static str = "export type GenericEnum<T, U> = \"Unit\" | { NewType: T } | { Seq: [T, U] } | { Map: { x: T; y: U } };";
Expand All @@ -33,18 +33,21 @@ const _: () = {
}
#[wasm_bindgen(typescript_custom_section)]
const TS_APPEND_CONTENT: &'static str = "export type GenericEnum<T, U> = \"Unit\" | { NewType: T } | { Seq: [T, U] } | { Map: { x: T; y: U } };";
#[automatically_derived]
impl<T, U> WasmDescribe for GenericEnum<T, U> {
#[inline]
fn describe() {
<Self as Tsify>::JsType::describe()
}
}
#[automatically_derived]
impl<T, U> WasmDescribeVector for GenericEnum<T, U> {
#[inline]
fn describe_vector() {
<Self as Tsify>::JsType::describe_vector()
}
}
#[automatically_derived]
impl<T, U> IntoWasmAbi for GenericEnum<T, U>
where
GenericEnum<T, U>: _serde::Serialize,
Expand Down Expand Up @@ -82,6 +85,7 @@ const _: () = {
}
}
}
#[automatically_derived]
impl<T, U> OptionIntoWasmAbi for GenericEnum<T, U>
where
GenericEnum<T, U>: _serde::Serialize,
Expand All @@ -91,6 +95,7 @@ const _: () = {
<JsType as OptionIntoWasmAbi>::none()
}
}
#[automatically_derived]
impl<T, U> From<GenericEnum<T, U>> for JsValue
where
GenericEnum<T, U>: _serde::Serialize,
Expand Down Expand Up @@ -127,6 +132,7 @@ const _: () = {
}
}
}
#[automatically_derived]
impl<T, U> VectorIntoWasmAbi for GenericEnum<T, U>
where
GenericEnum<T, U>: _serde::Serialize,
Expand Down Expand Up @@ -168,6 +174,7 @@ const _: () = {
JsValue::vector_into_abi(values)
}
}
#[automatically_derived]
impl<T, U> FromWasmAbi for GenericEnum<T, U>
where
Self: _serde::de::DeserializeOwned,
Expand All @@ -182,6 +189,7 @@ const _: () = {
result.unwrap_throw()
}
}
#[automatically_derived]
impl<T, U> OptionFromWasmAbi for GenericEnum<T, U>
where
Self: _serde::de::DeserializeOwned,
Expand All @@ -192,12 +200,14 @@ const _: () = {
}
}
pub struct SelfOwner<T>(T);
#[automatically_derived]
impl<T> ::core::ops::Deref for SelfOwner<T> {
type Target = T;
fn deref(&self) -> &Self::Target {
&self.0
}
}
#[automatically_derived]
impl<T, U> RefFromWasmAbi for GenericEnum<T, U>
where
Self: _serde::de::DeserializeOwned,
Expand All @@ -212,6 +222,7 @@ const _: () = {
SelfOwner(result.unwrap_throw())
}
}
#[automatically_derived]
impl<T, U> VectorFromWasmAbi for GenericEnum<T, U>
where
Self: _serde::de::DeserializeOwned,
Expand Down
Loading
Loading