Skip to content

Commit

Permalink
Converting Target::is_kind to accept an enum instead of String. This …
Browse files Browse the repository at this point in the history
…change is purely internal to the library
  • Loading branch information
michaelciraci committed Jan 20, 2024
1 parent 501a063 commit 6a6c3b7
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/lib.rs
Expand Up @@ -554,44 +554,43 @@ pub struct Target {
}

impl Target {
fn is_kind(&self, name: &str) -> bool {
let enum_kind: TargetKind = name.into();
self.kind.iter().any(|kind| kind == &enum_kind)
fn is_kind(&self, name: TargetKind) -> bool {
self.kind.iter().any(|kind| kind == &name)
}

/// Return true if this target is of kind "lib".
pub fn is_lib(&self) -> bool {
self.is_kind("lib")
self.is_kind(TargetKind::Lib)
}

/// Return true if this target is of kind "bin".
pub fn is_bin(&self) -> bool {
self.is_kind("bin")
self.is_kind(TargetKind::Bin)
}

/// Return true if this target is of kind "example".
pub fn is_example(&self) -> bool {
self.is_kind("example")
self.is_kind(TargetKind::Example)
}

/// Return true if this target is of kind "test".
pub fn is_test(&self) -> bool {
self.is_kind("test")
self.is_kind(TargetKind::Test)
}

/// Return true if this target is of kind "bench".
pub fn is_bench(&self) -> bool {
self.is_kind("bench")
self.is_kind(TargetKind::Bench)
}

/// Return true if this target is of kind "custom-build".
pub fn is_custom_build(&self) -> bool {
self.is_kind("custom-build")
self.is_kind(TargetKind::CustomBuild)
}

/// Return true if this target is of kind "proc-macro".
pub fn is_proc_macro(&self) -> bool {
self.is_kind("proc-macro")
self.is_kind(TargetKind::ProcMacro)
}
}

Expand Down

0 comments on commit 6a6c3b7

Please sign in to comment.