Skip to content

Commit 0ec2389

Browse files
committed
feat!: gix-config convenience initiative
A new `gix_config::AsKey` trait allows all `gix_config::File` methods to receive an implementation of `AsKey` instead of the tuple of `(section, subsection, value_name)`. This is the default, and all methods that take a tuple have been renamed to `<name>_by()`, note the `_by` suffix. The terminology was reworked so that `key` is now only used to identify a value. This change also affects the public API of `gix`, which provides ways to set values on configuration snapshots which now by default will only take a `AsKey` implementation. Note that `gix::config::tree::*` keys now also implement `AsKey`, which allows them to be used more conveniently when setting values, too.
1 parent dbe1f22 commit 0ec2389

File tree

47 files changed

+1042
-588
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1042
-588
lines changed

gix-config/fuzz/fuzz_targets/fuzz_file.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fn fuzz_immutable_section(section: &gix_config::file::Section<'_>, buf: &mut Vec
1717
let _ = black_box((key, value));
1818
}
1919
let mut seen = BTreeSet::new();
20-
for key in section.keys() {
20+
for key in section.value_names() {
2121
if seen.insert(key) {
2222
let _ = black_box(section.values(key.as_ref()));
2323
}
@@ -37,7 +37,7 @@ fn fuzz_mutable_section(
3737
// Mutate section.
3838
let section_id = {
3939
let mut section = file.section_mut(section_name, subsection_name)?;
40-
let key = section.keys().next().cloned();
40+
let key = section.value_names().next().cloned();
4141

4242
if let Some(key) = key {
4343
section.push_newline();

gix-config/src/file/access/comfort.rs

Lines changed: 96 additions & 81 deletions
Large diffs are not rendered by default.

gix-config/src/file/access/mutate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ impl<'event> File<'event> {
172172
/// # use gix_config::parse::section;
173173
/// let mut git_config = gix_config::File::default();
174174
/// let mut section = git_config.new_section("hello", Some(Cow::Borrowed("world".into())))?;
175-
/// section.push(section::Key::try_from("a")?, Some("b".into()));
175+
/// section.push(section::ValueName::try_from("a")?, Some("b".into()));
176176
/// let nl = section.newline().to_owned();
177177
/// assert_eq!(git_config.to_string(), format!("[hello \"world\"]{nl}\ta = b{nl}"));
178178
/// let _section = git_config.new_section("core", None);

0 commit comments

Comments
 (0)