Skip to content

Commit cdff759

Browse files
committed
Bump MSRV to 1.77
1 parent a09ad2e commit cdff759

38 files changed

+91
-107
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ keywords = ["opencv", "vision"]
88
license = "MIT"
99
version = "0.93.6"
1010
edition = "2021"
11-
rust-version = "1.66"
11+
rust-version = "1.77.0"
1212
authors = ["Pro <twisted.fall@gmail.com>", "Mathieu Poumeyrol <kali@zoy.org>"]
1313
exclude = ["/.github", "/ci", "/tools", ".editorconfig", ".gitattributes", ".gitignore", "release.toml", "rustfmt.toml"]
1414

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ The following OpenCV versions are supported at the moment:
163163

164164
### Minimum rustc version (MSRV)
165165

166-
Currently, Rust version 1.66.0 or later is required. General policy is that rust version from 1 year ago is supported.
166+
Currently, Rust version 1.77.0 or later is required. General policy is that rust version from 1 year ago is supported.
167167
Bumping versions older than that is not considered a breaking change.
168168

169169
### Platform support

binding-generator/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ version = "0.93.0"
66
license = "MIT"
77
authors = ["Pro <twisted.fall@gmail.com>"]
88
edition = "2021"
9-
rust-version = "1.65"
9+
rust-version = "1.77.0"
1010
exclude = ["release.toml"]
1111

1212
[lib]
@@ -15,7 +15,7 @@ exclude = ["release.toml"]
1515
clang = { version = "2", features = ["clang_6_0"] }
1616
clang-sys = { version = "1", features = ["clang_6_0"] }
1717
dunce = "1"
18-
once_cell = "1" # replace with std::sync::OnceLock when MSRV is 1.70
18+
once_cell = "1" # replace with std::sync::LazyLock when MSRV is 1.80
1919
percent-encoding = { version = "2", default-features = false }
2020
regex = "1"
2121
shlex = { version = "1.3", default-features = false }

binding-generator/src/bin/binding-generator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ fn main() {
6161
let mut args = env::args_os().skip(1);
6262
let mut opencv_header_dir = args.next();
6363
let mut debug = false;
64-
if opencv_header_dir.as_ref().map_or(false, |debug| debug == "--debug") {
64+
if opencv_header_dir.as_ref().is_some_and(|debug| debug == "--debug") {
6565
debug = true;
6666
opencv_header_dir = args.next();
6767
}

binding-generator/src/bin/settings-cleanup.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ struct FunctionFinder<'tu> {
1616
pub gen_env: GeneratorEnv<'tu>,
1717
}
1818

19-
impl<'tu> FunctionFinder<'tu> {
19+
impl FunctionFinder<'_> {
2020
pub fn update_used_func(&self, f: &Func) {
2121
let mut matcher = f.matcher();
2222
self.gen_env.settings.arg_override.get(&mut matcher);
@@ -32,7 +32,7 @@ impl<'tu> FunctionFinder<'tu> {
3232

3333
impl<'tu> EntityWalkerVisitor<'tu> for &mut FunctionFinder<'tu> {
3434
fn wants_file(&mut self, path: &Path) -> bool {
35-
opencv_module_from_path(path).map_or(false, |m| m == self.module)
35+
opencv_module_from_path(path) == Some(self.module)
3636
}
3737

3838
fn visit_entity(&mut self, entity: Entity<'tu>) -> ControlFlow<()> {
@@ -84,7 +84,7 @@ fn main() {
8484
.read_dir()
8585
.expect("Can't read dir")
8686
.map(|p| p.expect("Bad path").path())
87-
.filter(|p| p.is_file() && p.extension().map_or(false, |e| e == "hpp"))
87+
.filter(|p| p.is_file() && p.extension().is_some_and(|e| e == "hpp"))
8888
.filter_map(|mut p| {
8989
p.set_extension("");
9090
p.file_name().and_then(|f| f.to_str()).map(|f| f.to_string())

binding-generator/src/class.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl<'tu, 'ge> Class<'tu, 'ge> {
7575
&Self::Clang { entity, gen_env, .. } => {
7676
if settings::ELEMENT_EXCLUDE_KIND
7777
.get(self.cpp_name(CppNameStyle::Reference).as_ref())
78-
.map_or(false, |ek| ek.is_excluded())
78+
.is_some_and(|ek| ek.is_excluded())
7979
{
8080
return ClassKind::Other;
8181
}
@@ -221,8 +221,7 @@ impl<'tu, 'ge> Class<'tu, 'ge> {
221221
Class::Clang { entity, .. } => entity
222222
.walk_children_while(|f| {
223223
ControlFlow::continue_until(
224-
f.get_kind() == EntityKind::Destructor
225-
&& f.get_accessibility().map_or(true, |acc| acc != Accessibility::Public),
224+
f.get_kind() == EntityKind::Destructor && f.get_accessibility() != Some(Accessibility::Public),
226225
)
227226
})
228227
.is_break(),
@@ -427,11 +426,11 @@ impl<'tu, 'ge> Class<'tu, 'ge> {
427426
let fld_type_kind = fld_type_ref.kind();
428427
if fld_type_kind
429428
.as_pointer()
430-
.map_or(false, |inner| inner.kind().as_primitive().is_some())
429+
.is_some_and(|inner| inner.kind().as_primitive().is_some())
431430
&& !fld_type_kind.is_char_ptr_string(fld_type_ref.type_hint())
432431
{
433432
fld_type_ref.to_mut().set_type_hint(TypeRefTypeHint::PrimitivePtrAsRaw);
434-
} else if fld_type_kind.as_class().map_or(false, |cls| cls.kind().is_trait()) {
433+
} else if fld_type_kind.as_class().is_some_and(|cls| cls.kind().is_trait()) {
435434
fld_type_ref.to_mut().set_type_hint(TypeRefTypeHint::TraitClassConcrete);
436435
}
437436
}

binding-generator/src/comment.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub fn strip_doxygen_comment_markers(comment: &str) -> String {
1212
const SINGLELINE_SIDE: &str = "<";
1313

1414
fn trim_last_empty_lines(lines: &mut Vec<&str>) {
15-
while lines.last().map_or(false, |line| line.is_empty()) {
15+
while lines.last().is_some_and(|line| line.is_empty()) {
1616
lines.pop();
1717
}
1818
}

binding-generator/src/debug.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use clang::Entity;
77
use dunce::canonicalize;
88
use once_cell::sync::Lazy;
99

10-
pub static EMIT_DEBUG: Lazy<bool> = Lazy::new(|| env::var("OPENCV_BINDING_GENERATOR_EMIT_DEBUG").map_or(false, |v| v == "1"));
10+
pub static EMIT_DEBUG: Lazy<bool> = Lazy::new(|| env::var("OPENCV_BINDING_GENERATOR_EMIT_DEBUG").is_ok_and(|v| v == "1"));
1111

1212
#[derive(Clone, Debug)]
1313
pub struct LocationName<'me> {

binding-generator/src/element.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ impl DefaultElement {
1919
!this.is_public()
2020
|| settings::ELEMENT_EXCLUDE_KIND
2121
.get(cpp_refname.as_ref())
22-
.map_or(false, |ek| ek.is_ignored())
22+
.is_some_and(|ek| ek.is_ignored())
2323
})
2424
}
2525

binding-generator/src/field.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ impl<'tu, 'ge> Field<'tu, 'ge> {
9494
..
9595
} => {
9696
let type_ref_type_hint = type_ref_type_hint.clone().something_or_else(|| {
97-
let default_value_string = self.default_value().map_or(false, |def| def.contains(['"', '\'']));
97+
let default_value_string = self.default_value().is_some_and(|def| def.contains(['"', '\'']));
9898
if default_value_string {
9999
TypeRefTypeHint::CharAsRustChar
100100
} else {
@@ -210,7 +210,7 @@ impl<'tu, 'ge> Field<'tu, 'ge> {
210210
}
211211
} else {
212212
// check if still can be a slice arg length
213-
let can_be_slice_arg_len = kind.as_primitive().map_or(false, |(_, cpp)| {
213+
let can_be_slice_arg_len = kind.as_primitive().is_some_and(|(_, cpp)| {
214214
if cpp == "int" || cpp == "size_t" {
215215
let name = self.cpp_name(CppNameStyle::Declaration);
216216
name.ends_with('s') && name.contains('n') && name != "thickness" // fixme: have to exclude thickness

0 commit comments

Comments
 (0)