Skip to content

Commit

Permalink
fix: cargo lint
Browse files Browse the repository at this point in the history
  • Loading branch information
SyMind committed Sep 23, 2024
1 parent c69a361 commit f08b9da
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 19 deletions.
4 changes: 2 additions & 2 deletions crates/node_binding/binding.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ export class JsDependency {
get type(): string
get category(): string
get request(): string | undefined
get critical(): boolean | undefined
set critical(val?: boolean | undefined | null)
get critical(): boolean
set critical(val: boolean)
}

export class JsEntries {
Expand Down
2 changes: 1 addition & 1 deletion crates/rspack_binding_values/src/context_module_factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ impl JsContextModuleFactoryAfterResolveData {
.0
.dependencies
.iter_mut()
.map(|dep| JsDependency::new(dep))
.map(JsDependency::new)
.collect::<Vec<_>>()
}
}
Expand Down
27 changes: 11 additions & 16 deletions crates/rspack_binding_values/src/dependency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ impl JsCompiledDependency {
}
}

fn dependency<'a>(&self) -> &dyn Dependency {
fn dependency(&self) -> &dyn Dependency {
self
.module_graph
.dependency_by_id(&self.dependency_id)
.unwrap_or_else(|| panic!("Failed to get dependency by id = {:?}", &self.dependency_id))
.as_ref()
}

fn module_dependency<'a>(&self) -> Option<&dyn ModuleDependency> {
fn module_dependency(&self) -> Option<&dyn ModuleDependency> {
self.dependency().as_module_dependency()
}

fn context_dependency<'a>(&self) -> Option<&dyn ContextDependency> {
fn context_dependency(&self) -> Option<&dyn ContextDependency> {
self.dependency().as_context_dependency()
}
}
Expand Down Expand Up @@ -105,24 +105,19 @@ impl JsDependency {
}

#[napi(getter)]
pub fn critical(&self) -> napi::Either<bool, ()> {
pub fn critical(&self) -> bool {
match self.0.as_context_dependency() {
Some(dep) => napi::Either::A(dep.critical().is_some()),
None => napi::Either::B(()),
Some(dep) => dep.critical().is_some(),
None => false,
}
}

#[napi(setter)]
pub fn set_critical(&mut self, val: Option<bool>) {
if let Some(val) = val {
match self.0.as_context_dependency_mut() {
Some(dep) => {
let critical = dep.critical_mut();
if !val {
*critical = None;
}
}
None => (),
pub fn set_critical(&mut self, val: bool) {
if let Some(dep) = self.0.as_context_dependency_mut() {
let critical = dep.critical_mut();
if !val {
*critical = None;
}
}
}
Expand Down

0 comments on commit f08b9da

Please sign in to comment.