Skip to content

Commit cb86b83

Browse files
committed
Cleanup
1 parent 3045fa7 commit cb86b83

File tree

5 files changed

+7
-15
lines changed

5 files changed

+7
-15
lines changed

binding-generator/src/class.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ impl<'tu> EntityElement<'tu> for Class<'tu> {
283283
impl Element for Class<'_> {
284284
fn is_excluded(&self) -> bool {
285285
DefaultElement::is_excluded(self)
286-
|| match self.kind() { Kind::Excluded => true, _ => false }
286+
|| matches!(self.kind(), Kind::Excluded)
287287
|| self.cpp_namespace() == "" // we don't process out of namespace (legacy C) items, so mark them as excluded
288288
}
289289

binding-generator/src/type_ref.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -710,11 +710,7 @@ impl<'tu> TypeRef<'tu> {
710710
}
711711

712712
pub fn is_bool(&self) -> bool {
713-
if let Kind::Primitive("bool", _) = self.canonical().kind() {
714-
true
715-
} else {
716-
false
717-
}
713+
matches!(self.canonical().kind(), Kind::Primitive("bool", _))
718714
}
719715

720716
pub fn as_pointer(&self) -> Option<TypeRef<'tu>> {
@@ -1906,11 +1902,8 @@ impl<'tu> TypeRef<'tu> {
19061902
// return value is actually one of the arguments and if we free it (in post_call phase) before converting
19071903
// to string (in return statement) it will result in UB
19081904
pub fn cpp_arg_cleanup(&self, name: &str) -> String {
1909-
match self.as_string() {
1910-
Some(Dir::Out(StrType::CharPtr)) => {
1911-
return format!("delete[] {name}_out", name=name);
1912-
}
1913-
_ => {}
1905+
if let Some(Dir::Out(StrType::CharPtr)) = self.as_string() {
1906+
return format!("delete[] {name}_out", name=name);
19141907
}
19151908
"".to_string()
19161909
}

binding-generator/src/writer/rust_native/smart_ptr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl RustNativeGeneratedElement for SmartPtr<'_> {
9797
format!("new {typ}(val)", typ=pointee_type.cpp_full()).into()
9898
} else {
9999
let mut out = pointee_type.cpp_arg_func_call("val");
100-
if out.starts_with("*") {
100+
if out.starts_with('*') {
101101
out.to_mut().drain(..1);
102102
}
103103
out

binding-generator/src/writer/rust_native/typedef.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ impl RustNativeGeneratedElement for Typedef<'_> {
2424
|| include_str!("tpl/typedef/tpl.rs").compile_interpolation()
2525
);
2626
let underlying_type = self.underlying_type_ref();
27-
2827
let lifetimes = underlying_type.rust_lifetimes();
2928
let generic_args = if lifetimes.is_empty() {
3029
"".to_string()

tests/matx.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use matches::assert_matches;
22

33
use opencv::{
4-
core::{self, Matx22d, Matx23f, Matx32f, Matx33d, Matx44d, Matx66f, Point2f, Scalar},
4+
core::{self, Matx22d, Matx23f, Matx32f, Matx33d, Matx66f, Point2f, Scalar},
55
imgproc,
66
prelude::*,
77
Result,
@@ -51,7 +51,7 @@ fn matx_return() -> Result<()> {
5151
#[cfg(all(feature = "contrib", not(feature = "opencv-32")))]
5252
#[test]
5353
fn matx_arg() -> Result<()> {
54-
use opencv::surface_matching::Pose3D;
54+
use opencv::{core::Matx44d, surface_matching::Pose3D};
5555

5656
let mut pose = Pose3D::default()?;
5757
assert!(&pose.pose().val.iter().all(|&x| x == 0.));

0 commit comments

Comments
 (0)