Skip to content

Commit bf560df

Browse files
committed
move wasm-bindgen trait impls into one module to reduce verbosity
1 parent a9981b0 commit bf560df

File tree

1 file changed

+27
-50
lines changed

1 file changed

+27
-50
lines changed

src/datetime/mod.rs

Lines changed: 27 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1970,66 +1970,43 @@ impl From<DateTime<Utc>> for js_sys::Date {
19701970
feature = "wasmbind",
19711971
not(any(target_os = "emscripten", target_os = "wasi", target_os = "linux"))
19721972
))]
1973-
impl wasm_bindgen::convert::FromWasmAbi for DateTime<Utc> {
1974-
type Abi = <js_sys::Date as wasm_bindgen::convert::FromWasmAbi>::Abi;
1975-
unsafe fn from_abi(js: Self::Abi) -> Self {
1976-
unsafe { js_sys::Date::from_abi(js).into() }
1973+
mod wasm_impls {
1974+
impl wasm_bindgen::convert::FromWasmAbi for DateTime<Utc> {
1975+
type Abi = <js_sys::Date as wasm_bindgen::convert::FromWasmAbi>::Abi;
1976+
unsafe fn from_abi(js: Self::Abi) -> Self {
1977+
unsafe { js_sys::Date::from_abi(js).into() }
1978+
}
19771979
}
1978-
}
19791980

1980-
#[cfg(all(
1981-
target_arch = "wasm32",
1982-
feature = "wasmbind",
1983-
not(any(target_os = "emscripten", target_os = "wasi", target_os = "linux"))
1984-
))]
1985-
impl wasm_bindgen::convert::IntoWasmAbi for DateTime<Utc> {
1986-
type Abi = <js_sys::Date as wasm_bindgen::convert::IntoWasmAbi>::Abi;
1987-
fn into_abi(self) -> Self::Abi {
1988-
js_sys::Date::from(self).into_abi()
1981+
impl wasm_bindgen::convert::IntoWasmAbi for DateTime<Utc> {
1982+
type Abi = <js_sys::Date as wasm_bindgen::convert::IntoWasmAbi>::Abi;
1983+
fn into_abi(self) -> Self::Abi {
1984+
js_sys::Date::from(self).into_abi()
1985+
}
19891986
}
1990-
}
19911987

1992-
#[cfg(all(
1993-
target_arch = "wasm32",
1994-
feature = "wasmbind",
1995-
not(any(target_os = "emscripten", target_os = "wasi", target_os = "linux"))
1996-
))]
1997-
impl wasm_bindgen::describe::WasmDescribe for DateTime<Utc> {
1998-
fn describe() {
1999-
js_sys::Date::describe()
1988+
impl wasm_bindgen::describe::WasmDescribe for DateTime<Utc> {
1989+
fn describe() {
1990+
js_sys::Date::describe()
1991+
}
20001992
}
2001-
}
20021993

2003-
#[cfg(all(
2004-
target_arch = "wasm32",
2005-
feature = "wasmbind",
2006-
not(any(target_os = "emscripten", target_os = "wasi", target_os = "linux"))
2007-
))]
2008-
impl wasm_bindgen::describe::WasmDescribeVector for DateTime<Utc> {
2009-
fn describe_vector() {
2010-
js_sys::Date::describe_vector()
1994+
impl wasm_bindgen::describe::WasmDescribeVector for DateTime<Utc> {
1995+
fn describe_vector() {
1996+
js_sys::Date::describe_vector()
1997+
}
20111998
}
2012-
}
20131999

2014-
#[cfg(all(
2015-
target_arch = "wasm32",
2016-
feature = "wasmbind",
2017-
not(any(target_os = "emscripten", target_os = "wasi", target_os = "linux"))
2018-
))]
2019-
impl wasm_bindgen::convert::OptionFromWasmAbi for DateTime<Utc> {
2020-
fn is_none(abi: &Self::Abi) -> bool {
2021-
js_sys::Date::is_none(abi)
2000+
impl wasm_bindgen::convert::OptionFromWasmAbi for DateTime<Utc> {
2001+
fn is_none(abi: &Self::Abi) -> bool {
2002+
js_sys::Date::is_none(abi)
2003+
}
20222004
}
2023-
}
20242005

2025-
#[cfg(all(
2026-
target_arch = "wasm32",
2027-
feature = "wasmbind",
2028-
not(any(target_os = "emscripten", target_os = "wasi", target_os = "linux"))
2029-
))]
2030-
impl wasm_bindgen::convert::OptionIntoWasmAbi for DateTime<Utc> {
2031-
fn none() -> Self::Abi {
2032-
js_sys::Date::none()
2006+
impl wasm_bindgen::convert::OptionIntoWasmAbi for DateTime<Utc> {
2007+
fn none() -> Self::Abi {
2008+
js_sys::Date::none()
2009+
}
20332010
}
20342011
}
20352012

0 commit comments

Comments
 (0)