Skip to content
This repository was archived by the owner on Dec 14, 2024. It is now read-only.

Commit b3c17be

Browse files
committed
style: rustfmt + clippy fixes
1 parent 61839af commit b3c17be

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

napi/transform/src/options.rs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pub struct JsTransformOptions {
77
#[napi(ts_type = "ReactOptions")]
88
pub react: JsReactOptions,
99
#[napi(ts_type = "MinifyOptions")]
10-
pub codegen: JsCodegenOptions
10+
pub codegen: JsCodegenOptions,
1111
}
1212

1313
impl From<JsTransformOptions> for TransformOptions {
@@ -26,14 +26,14 @@ impl From<JsTransformOptions> for TransformOptions {
2626
pub struct JsCodegenOptions {
2727
#[napi(ts_type = "CompressOption | boolean")]
2828
pub compress: CompressOption,
29-
pub source_map: bool
29+
pub source_map: bool,
3030
}
3131

3232
impl Default for JsCodegenOptions {
3333
fn default() -> Self {
3434
Self {
3535
compress: Default::default(),
36-
source_map: true
36+
source_map: true,
3737
}
3838
}
3939
}
@@ -44,7 +44,7 @@ pub enum CompressOption {
4444
#[default]
4545
None,
4646
Whitespace,
47-
Fold
47+
Fold,
4848
}
4949

5050
impl CompressOption {
@@ -74,8 +74,7 @@ impl TryFrom<i32> for CompressOption {
7474
2 => Ok(Self::Fold),
7575
n => Err(napi::Error::new(
7676
napi::Status::InvalidArg,
77-
format!(
78-
"Invalid CompressOption value `{n}`: must be 0, 1, or 2."),
77+
format!("Invalid CompressOption value `{n}`: must be 0, 1, or 2."),
7978
)),
8079
}
8180
}
@@ -91,24 +90,29 @@ impl TypeName for CompressOption {
9190
}
9291

9392
impl FromNapiValue for CompressOption {
94-
unsafe fn from_napi_value(env: napi::sys::napi_env, napi_val: napi::sys::napi_value) -> napi::Result<Self> {
93+
unsafe fn from_napi_value(
94+
env: napi::sys::napi_env,
95+
napi_val: napi::sys::napi_value,
96+
) -> napi::Result<Self> {
9597
match type_of!(env, napi_val) {
96-
Ok(ValueType::Undefined | ValueType::Null) => return Ok(Self::None),
98+
Ok(ValueType::Undefined | ValueType::Null) => Ok(Self::None),
9799
Ok(ValueType::Boolean) => {
98100
bool::from_napi_value(env, napi_val).map(CompressOption::from)
99101
}
100102
Ok(ValueType::Number) => {
101103
i32::from_napi_value(env, napi_val).and_then(CompressOption::try_from)
102104
}
103105
Ok(_) => todo!(),
104-
Err(e) => Err(e)
106+
Err(e) => Err(e),
105107
}
106-
107108
}
108109
}
109110

110111
impl ToNapiValue for CompressOption {
111-
unsafe fn to_napi_value(env: napi::sys::napi_env, val: Self) -> napi::Result<napi::sys::napi_value> {
112+
unsafe fn to_napi_value(
113+
env: napi::sys::napi_env,
114+
val: Self,
115+
) -> napi::Result<napi::sys::napi_value> {
112116
let val = match val {
113117
CompressOption::None => 0,
114118
CompressOption::Whitespace => 1,

0 commit comments

Comments
 (0)