@@ -15,7 +15,7 @@ impl<'event> File<'event> {
15
15
/// Returns the last mutable section with a given `name` and optional `subsection_name`, _if it exists_.
16
16
pub fn section_mut < ' a > (
17
17
& ' a mut self ,
18
- name : impl AsRef < str > ,
18
+ name : & str ,
19
19
subsection_name : Option < & BStr > ,
20
20
) -> Result < SectionMut < ' a , ' event > , lookup:: existing:: Error > {
21
21
let id = self
@@ -31,10 +31,7 @@ impl<'event> File<'event> {
31
31
}
32
32
33
33
/// Returns the last found mutable section with a given `key`, identifying the name and subsection name like `core` or `remote.origin`.
34
- pub fn section_mut_by_key < ' a , ' b > (
35
- & ' a mut self ,
36
- key : impl Into < & ' b BStr > ,
37
- ) -> Result < SectionMut < ' a , ' event > , lookup:: existing:: Error > {
34
+ pub fn section_mut_by_key < ' a > ( & ' a mut self , key : & BStr ) -> Result < SectionMut < ' a , ' event > , lookup:: existing:: Error > {
38
35
let key = section:: unvalidated:: Key :: parse ( key) . ok_or ( lookup:: existing:: Error :: KeyMissing ) ?;
39
36
self . section_mut ( key. section_name , key. subsection_name )
40
37
}
@@ -50,7 +47,7 @@ impl<'event> File<'event> {
50
47
/// Returns the last mutable section with a given `name` and optional `subsection_name`, _if it exists_, or create a new section.
51
48
pub fn section_mut_or_create_new < ' a > (
52
49
& ' a mut self ,
53
- name : impl AsRef < str > ,
50
+ name : & str ,
54
51
subsection_name : Option < & BStr > ,
55
52
) -> Result < SectionMut < ' a , ' event > , section:: header:: Error > {
56
53
self . section_mut_or_create_new_filter ( name, subsection_name, & mut |_| true )
@@ -60,11 +57,10 @@ impl<'event> File<'event> {
60
57
/// a new section.
61
58
pub fn section_mut_or_create_new_filter < ' a > (
62
59
& ' a mut self ,
63
- name : impl AsRef < str > ,
60
+ name : & str ,
64
61
subsection_name : Option < & BStr > ,
65
62
filter : & mut MetadataFilter ,
66
63
) -> Result < SectionMut < ' a , ' event > , section:: header:: Error > {
67
- let name = name. as_ref ( ) ;
68
64
match self
69
65
. section_ids_by_name_and_subname ( name. as_ref ( ) , subsection_name)
70
66
. ok ( )
@@ -82,7 +78,10 @@ impl<'event> File<'event> {
82
78
. expect ( "BUG: Section did not have id from lookup" )
83
79
. to_mut ( nl) )
84
80
}
85
- None => self . new_section ( name. to_owned ( ) , subsection_name. map ( |n| Cow :: Owned ( n. to_owned ( ) ) ) ) ,
81
+ None => self . new_section (
82
+ name. to_owned ( ) . into ( ) ,
83
+ subsection_name. map ( |n| Cow :: Owned ( n. to_owned ( ) ) ) ,
84
+ ) ,
86
85
}
87
86
}
88
87
@@ -92,7 +91,7 @@ impl<'event> File<'event> {
92
91
/// is returned.
93
92
pub fn section_mut_filter < ' a > (
94
93
& ' a mut self ,
95
- name : impl AsRef < str > ,
94
+ name : & str ,
96
95
subsection_name : Option < & BStr > ,
97
96
filter : & mut MetadataFilter ,
98
97
) -> Result < Option < file:: SectionMut < ' a , ' event > > , lookup:: existing:: Error > {
@@ -109,9 +108,9 @@ impl<'event> File<'event> {
109
108
110
109
/// Like [`section_mut_filter()`][File::section_mut_filter()], but identifies the with a given `key`,
111
110
/// like `core` or `remote.origin`.
112
- pub fn section_mut_filter_by_key < ' a , ' b > (
111
+ pub fn section_mut_filter_by_key < ' a > (
113
112
& ' a mut self ,
114
- key : impl Into < & ' b BStr > ,
113
+ key : & BStr ,
115
114
filter : & mut MetadataFilter ,
116
115
) -> Result < Option < file:: SectionMut < ' a , ' event > > , lookup:: existing:: Error > {
117
116
let key = section:: unvalidated:: Key :: parse ( key) . ok_or ( lookup:: existing:: Error :: KeyMissing ) ?;
@@ -131,7 +130,7 @@ impl<'event> File<'event> {
131
130
/// # use gix_config::File;
132
131
/// # use std::convert::TryFrom;
133
132
/// let mut git_config = gix_config::File::default();
134
- /// let section = git_config.new_section("hello", Some(Cow::Borrowed("world".into())))?;
133
+ /// let section = git_config.new_section("hello".into() , Some(Cow::Borrowed("world".into())))?;
135
134
/// let nl = section.newline().to_owned();
136
135
/// assert_eq!(git_config.to_string(), format!("[hello \"world\"]{nl}"));
137
136
/// # Ok::<(), Box<dyn std::error::Error>>(())
@@ -146,18 +145,18 @@ impl<'event> File<'event> {
146
145
/// # use bstr::ByteSlice;
147
146
/// # use gix_config::parse::section;
148
147
/// let mut git_config = gix_config::File::default();
149
- /// let mut section = git_config.new_section("hello", Some(Cow::Borrowed("world".into())))?;
148
+ /// let mut section = git_config.new_section("hello".into() , Some(Cow::Borrowed("world".into())))?;
150
149
/// section.push(section::Key::try_from("a")?, Some("b".into()));
151
150
/// let nl = section.newline().to_owned();
152
151
/// assert_eq!(git_config.to_string(), format!("[hello \"world\"]{nl}\ta = b{nl}"));
153
- /// let _section = git_config.new_section("core", None);
152
+ /// let _section = git_config.new_section("core".into() , None);
154
153
/// assert_eq!(git_config.to_string(), format!("[hello \"world\"]{nl}\ta = b{nl}[core]{nl}"));
155
154
/// # Ok::<(), Box<dyn std::error::Error>>(())
156
155
/// ```
157
156
pub fn new_section (
158
157
& mut self ,
159
- name : impl Into < Cow < ' event , str > > ,
160
- subsection : impl Into < Option < Cow < ' event , BStr > > > ,
158
+ name : Cow < ' event , str > ,
159
+ subsection : Option < Cow < ' event , BStr > > ,
161
160
) -> Result < SectionMut < ' _ , ' event > , section:: header:: Error > {
162
161
let id = self . push_section_internal ( file:: Section :: new ( name, subsection, OwnShared :: clone ( & self . meta ) ) ?) ;
163
162
let nl = self . detect_newline_style_smallvec ( ) ;
@@ -203,11 +202,7 @@ impl<'event> File<'event> {
203
202
/// assert_eq!(git_config.to_string(), "[hello \"world\"]\n some-value = 4\n");
204
203
/// # Ok::<(), Box<dyn std::error::Error>>(())
205
204
/// ```
206
- pub fn remove_section < ' a > (
207
- & mut self ,
208
- name : & str ,
209
- subsection_name : impl Into < Option < & ' a BStr > > ,
210
- ) -> Option < file:: Section < ' event > > {
205
+ pub fn remove_section ( & mut self , name : & str , subsection_name : Option < & BStr > ) -> Option < file:: Section < ' event > > {
211
206
let id = self
212
207
. section_ids_by_name_and_subname ( name, subsection_name. into ( ) )
213
208
. ok ( ) ?
@@ -252,10 +247,10 @@ impl<'event> File<'event> {
252
247
/// if at least one section matched the `filter`.
253
248
/// If multiple sections have the same name, then the last one is returned. Note that
254
249
/// later sections with the same name have precedent over earlier ones.
255
- pub fn remove_section_filter < ' a > (
250
+ pub fn remove_section_filter (
256
251
& mut self ,
257
252
name : & str ,
258
- subsection_name : impl Into < Option < & ' a BStr > > ,
253
+ subsection_name : Option < & BStr > ,
259
254
filter : & mut MetadataFilter ,
260
255
) -> Option < file:: Section < ' event > > {
261
256
let id = self
@@ -283,12 +278,12 @@ impl<'event> File<'event> {
283
278
284
279
/// Renames the section with `name` and `subsection_name`, modifying the last matching section
285
280
/// to use `new_name` and `new_subsection_name`.
286
- pub fn rename_section < ' a > (
281
+ pub fn rename_section (
287
282
& mut self ,
288
- name : impl AsRef < str > ,
289
- subsection_name : impl Into < Option < & ' a BStr > > ,
290
- new_name : impl Into < Cow < ' event , str > > ,
291
- new_subsection_name : impl Into < Option < Cow < ' event , BStr > > > ,
283
+ name : & str ,
284
+ subsection_name : Option < & BStr > ,
285
+ new_name : Cow < ' event , str > ,
286
+ new_subsection_name : Option < Cow < ' event , BStr > > ,
292
287
) -> Result < ( ) , rename_section:: Error > {
293
288
let id = self
294
289
. section_ids_by_name_and_subname ( name. as_ref ( ) , subsection_name. into ( ) ) ?
@@ -304,12 +299,12 @@ impl<'event> File<'event> {
304
299
///
305
300
/// Note that the otherwise unused [`lookup::existing::Error::KeyMissing`] variant is used to indicate
306
301
/// that the `filter` rejected all candidates, leading to no section being renamed after all.
307
- pub fn rename_section_filter < ' a > (
302
+ pub fn rename_section_filter (
308
303
& mut self ,
309
- name : impl AsRef < str > ,
310
- subsection_name : impl Into < Option < & ' a BStr > > ,
311
- new_name : impl Into < Cow < ' event , str > > ,
312
- new_subsection_name : impl Into < Option < Cow < ' event , BStr > > > ,
304
+ name : & str ,
305
+ subsection_name : Option < & BStr > ,
306
+ new_name : Cow < ' event , str > ,
307
+ new_subsection_name : Option < Cow < ' event , BStr > > ,
313
308
filter : & mut MetadataFilter ,
314
309
) -> Result < ( ) , rename_section:: Error > {
315
310
let id = self
0 commit comments