Skip to content

Commit

Permalink
fix: Assure gix-submodule works with Rust 1.65.
Browse files Browse the repository at this point in the history
The previous version of this loop, possibly preferable, ran into
a borrow-check issue that was no more from Rust 1.70 onwards.
  • Loading branch information
Byron committed Aug 21, 2023
1 parent 2650843 commit 8172f0e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/msrv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: dtolnay/[email protected] # dictated by `windows` crates effectively, IMPORTANT: adjust etc/msrv-badge.svg as well
- uses: dtolnay/[email protected] # dictated by `firefox` to support the `helix` editor, IMPORTANT: adjust etc/msrv-badge.svg as well
- uses: extractions/setup-just@v1
- run: just ci-check-msrv
2 changes: 1 addition & 1 deletion etc/msrv-badge.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 10 additions & 12 deletions gix-submodule/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,20 @@ impl File {

let mut config_to_append = gix_config::File::new(config.meta_owned());
let mut prev_name = None;
let mut section = None;
for ((module_name, field), values) in values {
if prev_name.map_or(true, |pn: &BStr| pn != module_name) {
section.take();
section = Some(
config_to_append
.new_section("submodule", Cow::Owned(module_name.to_owned()))
.expect("all names come from valid configuration, so remain valid"),
);
config_to_append
.new_section("submodule", Cow::Owned(module_name.to_owned()))
.expect("all names come from valid configuration, so remain valid");
prev_name = Some(module_name);
}
let section = section.as_mut().expect("always set at this point");
section.push(
field.try_into().expect("statically known key"),
Some(values.last().expect("at least one value or we wouldn't be here")),
);
config_to_append
.section_mut("submodule", Some(module_name))
.expect("always set at this point")
.push(
field.try_into().expect("statically known key"),
Some(values.last().expect("at least one value or we wouldn't be here")),
);
}

self.config.append(config_to_append);
Expand Down

0 comments on commit 8172f0e

Please sign in to comment.