Skip to content

Commit d14c2fc

Browse files
committed
Cleanup
1 parent 97dcbd0 commit d14c2fc

File tree

6 files changed

+17
-12
lines changed

6 files changed

+17
-12
lines changed

binding-generator/src/writer/rust_native/class/gen.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,7 @@ pub fn extern_functions<'tu, 'ge>(c: &Class<'tu, 'ge>) -> Vec<Func<'tu, 'ge>> {
188188
let mut out = c
189189
.methods(|m| m.exclude_kind().is_included())
190190
.into_iter()
191-
.flat_map(|m| {
192-
let companion_func = m.companion_functions();
193-
iter::once(m).chain(companion_func)
194-
})
191+
.flat_map(|m| m.with_companion_functions())
195192
.collect::<Vec<_>>();
196193

197194
if c.has_implicit_clone() {

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

+11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
use std::borrow::Cow;
22
use std::collections::HashMap;
33
use std::fmt::Write;
4+
use std::iter;
5+
use std::iter::{Chain, Once};
46
use std::rc::Rc;
7+
use std::vec::IntoIter;
58

69
use once_cell::sync::Lazy;
710
use Cow::{Borrowed, Owned};
@@ -20,6 +23,9 @@ use crate::{reserved_rename, CompiledInterpolation, Element, Func, IteratorExt,
2023

2124
pub trait FuncExt<'tu, 'ge> {
2225
fn companion_functions(&self) -> Vec<Func<'tu, 'ge>>;
26+
fn with_companion_functions(self) -> Chain<Once<Self>, IntoIter<Self>>
27+
where
28+
Self: Sized;
2329
}
2430

2531
impl<'tu, 'ge> FuncExt<'tu, 'ge> for Func<'tu, 'ge> {
@@ -32,6 +38,11 @@ impl<'tu, 'ge> FuncExt<'tu, 'ge> for Func<'tu, 'ge> {
3238
out.extend(companion_func_boxref_mut(self));
3339
out
3440
}
41+
42+
fn with_companion_functions(self) -> Chain<Once<Self>, IntoIter<Self>> {
43+
let companions = self.companion_functions();
44+
iter::once(self).chain(companions)
45+
}
3546
}
3647

3748
impl RustElement for Func<'_, '_> {

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,7 @@ impl GeneratorVisitor<'_> for RustNativeBindingWriter<'_> {
136136

137137
fn visit_func(&mut self, func: Func) {
138138
self.emit_debug_log(&func);
139-
let companion_funcs = func.companion_functions();
140-
for func in iter::once(func).chain(companion_funcs) {
139+
for func in func.with_companion_functions() {
141140
let name = func.identifier();
142141
self.rust_funcs.push((name.clone(), func.gen_rust(self.opencv_version)));
143142
self.extern_funcs.push((name.clone(), func.gen_rust_externs()));

binding-generator/src/writer/rust_native/type_ref/render_lane.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ pub enum Indirection {
109109
}
110110

111111
impl fmt::Debug for RenderLane<'_, '_> {
112-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
112+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
113113
match self {
114114
RenderLane::Primitive(_) => f.write_str("Primitive"),
115115
RenderLane::InString(_) => f.write_str("InString"),

ci/script.sh

+1-3
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,7 @@ cargo test -vv --features "$FEATURES"
9393
cargo test --release -vv --features "$FEATURES"
9494
cargo test --release -vv --features "$FEATURES,clang-runtime"
9595

96-
pushd ci/test-proj
97-
cargo run -vv
98-
popd
96+
cargo run --manifest-path=ci/test-proj/Cargo.toml -vv
9997

10098
export CXX=clang++
10199
touch build.rs

ci/test-proj/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ name = "test-proj"
33
description = "Helper to test whether project using opencv dependency compiles"
44
version = "0.1.0"
55
authors = ["Pro"]
6-
edition = "2018"
6+
edition = "2021"
77

88
[dependencies]
99
opencv = { path = "../..", features = ["clang-runtime"] }
10-
bindgen = { version = "0.60", features= ["runtime"] }
10+
bindgen = { version = "0.71", features = ["runtime"] }
1111

1212
[workspace]

0 commit comments

Comments
 (0)