@@ -2,13 +2,14 @@ use std::borrow::Cow;
22
33use  bstr:: BStr ; 
44
5- use  crate :: { file:: MetadataFilter ,  value,  AsKey ,  File } ; 
5+ use  crate :: file:: Metadata ; 
6+ use  crate :: { value,  AsKey ,  File } ; 
67
78/// Comfortable API for accessing values 
89impl  File < ' _ >  { 
910    /// Like [`string_by()`](File::string_by()), but suitable for statically known `key`s like `remote.origin.url`. 
1011pub  fn  string ( & self ,  key :  impl  AsKey )  -> Option < Cow < ' _ ,  BStr > >  { 
11-         self . string_filter ( key,  & mut   |_| true ) 
12+         self . string_filter ( key,  |_| true ) 
1213    } 
1314
1415    /// Like [`value()`](File::value()), but returning `None` if the string wasn't found. 
@@ -20,13 +21,11 @@ impl File<'_> {
2021        subsection_name :  Option < & BStr > , 
2122        value_name :  impl  AsRef < str > , 
2223    )  -> Option < Cow < ' _ ,  BStr > >  { 
23-         self . string_filter_by ( section_name. as_ref ( ) ,  subsection_name,  value_name. as_ref ( ) ,  & mut  |_| { 
24-             true 
25-         } ) 
24+         self . string_filter_by ( section_name. as_ref ( ) ,  subsection_name,  value_name. as_ref ( ) ,  |_| true ) 
2625    } 
2726
2827    /// Like [`string_filter_by()`](File::string_filter_by()), but suitable for statically known `key`s like `remote.origin.url`. 
29- pub  fn  string_filter ( & self ,  key :  impl  AsKey ,  filter :  & mut   MetadataFilter )  -> Option < Cow < ' _ ,  BStr > >  { 
28+ pub  fn  string_filter ( & self ,  key :  impl  AsKey ,  filter :  impl   FnMut ( & Metadata )  ->  bool )  -> Option < Cow < ' _ ,  BStr > >  { 
3029        let  key = key. try_as_key ( ) ?; 
3130        self . raw_value_filter_by ( key. section_name ,  key. subsection_name ,  key. value_name ,  filter) 
3231            . ok ( ) 
@@ -38,15 +37,15 @@ impl File<'_> {
3837        section_name :  impl  AsRef < str > , 
3938        subsection_name :  Option < & BStr > , 
4039        value_name :  impl  AsRef < str > , 
41-         filter :  & mut   MetadataFilter , 
40+         filter :  impl   FnMut ( & Metadata )  ->  bool , 
4241    )  -> Option < Cow < ' _ ,  BStr > >  { 
4342        self . raw_value_filter_by ( section_name. as_ref ( ) ,  subsection_name,  value_name. as_ref ( ) ,  filter) 
4443            . ok ( ) 
4544    } 
4645
4746    /// Like [`path_by()`](File::path_by()), but suitable for statically known `key`s like `remote.origin.url`. 
4847pub  fn  path ( & self ,  key :  impl  AsKey )  -> Option < crate :: Path < ' _ > >  { 
49-         self . path_filter ( key,  & mut   |_| true ) 
48+         self . path_filter ( key,  |_| true ) 
5049    } 
5150
5251    /// Like [`value()`](File::value()), but returning `None` if the path wasn't found. 
@@ -61,13 +60,11 @@ impl File<'_> {
6160        subsection_name :  Option < & BStr > , 
6261        value_name :  impl  AsRef < str > , 
6362    )  -> Option < crate :: Path < ' _ > >  { 
64-         self . path_filter_by ( section_name. as_ref ( ) ,  subsection_name,  value_name. as_ref ( ) ,  & mut  |_| { 
65-             true 
66-         } ) 
63+         self . path_filter_by ( section_name. as_ref ( ) ,  subsection_name,  value_name. as_ref ( ) ,  |_| true ) 
6764    } 
6865
6966    /// Like [`path_filter_by()`](File::path_filter_by()), but suitable for statically known `key`s like `remote.origin.url`. 
70- pub  fn  path_filter ( & self ,  key :  impl  AsKey ,  filter :  & mut   MetadataFilter )  -> Option < crate :: Path < ' _ > >  { 
67+ pub  fn  path_filter ( & self ,  key :  impl  AsKey ,  filter :  impl   FnMut ( & Metadata )  ->  bool )  -> Option < crate :: Path < ' _ > >  { 
7168        let  key = key. try_as_key ( ) ?; 
7269        self . path_filter_by ( key. section_name ,  key. subsection_name ,  key. value_name ,  filter) 
7370    } 
@@ -83,7 +80,7 @@ impl File<'_> {
8380        section_name :  impl  AsRef < str > , 
8481        subsection_name :  Option < & BStr > , 
8582        value_name :  impl  AsRef < str > , 
86-         filter :  & mut   MetadataFilter , 
83+         filter :  impl   FnMut ( & Metadata )  ->  bool , 
8784    )  -> Option < crate :: Path < ' _ > >  { 
8885        self . raw_value_filter_by ( section_name. as_ref ( ) ,  subsection_name,  value_name. as_ref ( ) ,  filter) 
8986            . ok ( ) 
@@ -92,7 +89,7 @@ impl File<'_> {
9289
9390    /// Like [`boolean_by()`](File::boolean_by()), but suitable for statically known `key`s like `remote.origin.url`. 
9491pub  fn  boolean ( & self ,  key :  impl  AsKey )  -> Option < Result < bool ,  value:: Error > >  { 
95-         self . boolean_filter ( key,  & mut   |_| true ) 
92+         self . boolean_filter ( key,  |_| true ) 
9693    } 
9794
9895    /// Like [`value()`](File::value()), but returning `None` if the boolean value wasn't found. 
@@ -102,13 +99,15 @@ impl File<'_> {
10299        subsection_name :  Option < & BStr > , 
103100        value_name :  impl  AsRef < str > , 
104101    )  -> Option < Result < bool ,  value:: Error > >  { 
105-         self . boolean_filter_by ( section_name. as_ref ( ) ,  subsection_name,  value_name. as_ref ( ) ,  & mut  |_| { 
106-             true 
107-         } ) 
102+         self . boolean_filter_by ( section_name. as_ref ( ) ,  subsection_name,  value_name. as_ref ( ) ,  |_| true ) 
108103    } 
109104
110105    /// Like [`boolean_filter_by()`](File::boolean_filter_by()), but suitable for statically known `key`s like `remote.origin.url`. 
111- pub  fn  boolean_filter ( & self ,  key :  impl  AsKey ,  filter :  & mut  MetadataFilter )  -> Option < Result < bool ,  value:: Error > >  { 
106+ pub  fn  boolean_filter ( 
107+         & self , 
108+         key :  impl  AsKey , 
109+         filter :  impl  FnMut ( & Metadata )  -> bool , 
110+     )  -> Option < Result < bool ,  value:: Error > >  { 
112111        let  key = key. try_as_key ( ) ?; 
113112        self . boolean_filter_by ( key. section_name ,  key. subsection_name ,  key. value_name ,  filter) 
114113    } 
@@ -119,7 +118,7 @@ impl File<'_> {
119118        section_name :  impl  AsRef < str > , 
120119        subsection_name :  Option < & BStr > , 
121120        value_name :  impl  AsRef < str > , 
122-         filter :  & mut   MetadataFilter , 
121+         mut   filter :  impl   FnMut ( & Metadata )  ->  bool , 
123122    )  -> Option < Result < bool ,  value:: Error > >  { 
124123        let  section_name = section_name. as_ref ( ) ; 
125124        let  section_ids = self 
@@ -142,7 +141,7 @@ impl File<'_> {
142141
143142    /// Like [`integer_by()`](File::integer_by()), but suitable for statically known `key`s like `remote.origin.url`. 
144143pub  fn  integer ( & self ,  key :  impl  AsKey )  -> Option < Result < i64 ,  value:: Error > >  { 
145-         self . integer_filter ( key,  & mut   |_| true ) 
144+         self . integer_filter ( key,  |_| true ) 
146145    } 
147146
148147    /// Like [`value()`](File::value()), but returning an `Option` if the integer wasn't found. 
@@ -152,11 +151,15 @@ impl File<'_> {
152151        subsection_name :  Option < & BStr > , 
153152        value_name :  impl  AsRef < str > , 
154153    )  -> Option < Result < i64 ,  value:: Error > >  { 
155-         self . integer_filter_by ( section_name,  subsection_name,  value_name,  & mut   |_| true ) 
154+         self . integer_filter_by ( section_name,  subsection_name,  value_name,  |_| true ) 
156155    } 
157156
158157    /// Like [`integer_filter_by()`](File::integer_filter_by()), but suitable for statically known `key`s like `remote.origin.url`. 
159- pub  fn  integer_filter ( & self ,  key :  impl  AsKey ,  filter :  & mut  MetadataFilter )  -> Option < Result < i64 ,  value:: Error > >  { 
158+ pub  fn  integer_filter ( 
159+         & self , 
160+         key :  impl  AsKey , 
161+         filter :  impl  FnMut ( & Metadata )  -> bool , 
162+     )  -> Option < Result < i64 ,  value:: Error > >  { 
160163        let  key = key. try_as_key ( ) ?; 
161164        self . integer_filter_by ( key. section_name ,  key. subsection_name ,  key. value_name ,  filter) 
162165    } 
@@ -167,7 +170,7 @@ impl File<'_> {
167170        section_name :  impl  AsRef < str > , 
168171        subsection_name :  Option < & BStr > , 
169172        value_name :  impl  AsRef < str > , 
170-         filter :  & mut   MetadataFilter , 
173+         filter :  impl   FnMut ( & Metadata )  ->  bool , 
171174    )  -> Option < Result < i64 ,  value:: Error > >  { 
172175        let  int = self 
173176            . raw_value_filter_by ( section_name. as_ref ( ) ,  subsection_name,  value_name. as_ref ( ) ,  filter) 
@@ -196,7 +199,7 @@ impl File<'_> {
196199    } 
197200
198201    /// Like [`strings_filter_by()`](File::strings_filter_by()), but suitable for statically known `key`s like `remote.origin.url`. 
199- pub  fn  strings_filter ( & self ,  key :  impl  AsKey ,  filter :  & mut   MetadataFilter )  -> Option < Vec < Cow < ' _ ,  BStr > > >  { 
202+ pub  fn  strings_filter ( & self ,  key :  impl  AsKey ,  filter :  impl   FnMut ( & Metadata )  ->  bool )  -> Option < Vec < Cow < ' _ ,  BStr > > >  { 
200203        let  key = key. try_as_key ( ) ?; 
201204        self . strings_filter_by ( key. section_name ,  key. subsection_name ,  key. value_name ,  filter) 
202205    } 
@@ -207,15 +210,15 @@ impl File<'_> {
207210        section_name :  impl  AsRef < str > , 
208211        subsection_name :  Option < & BStr > , 
209212        value_name :  impl  AsRef < str > , 
210-         filter :  & mut   MetadataFilter , 
213+         filter :  impl   FnMut ( & Metadata )  ->  bool , 
211214    )  -> Option < Vec < Cow < ' _ ,  BStr > > >  { 
212215        self . raw_values_filter_by ( section_name. as_ref ( ) ,  subsection_name,  value_name. as_ref ( ) ,  filter) 
213216            . ok ( ) 
214217    } 
215218
216219    /// Like [`integers()`](File::integers()), but suitable for statically known `key`s like `remote.origin.url`. 
217220pub  fn  integers ( & self ,  key :  impl  AsKey )  -> Option < Result < Vec < i64 > ,  value:: Error > >  { 
218-         self . integers_filter ( key,  & mut   |_| true ) 
221+         self . integers_filter ( key,  |_| true ) 
219222    } 
220223
221224    /// Similar to [`values_by(…)`](File::values_by()) but returning integers if at least one of them was found 
@@ -226,16 +229,14 @@ impl File<'_> {
226229        subsection_name :  Option < & BStr > , 
227230        value_name :  impl  AsRef < str > , 
228231    )  -> Option < Result < Vec < i64 > ,  value:: Error > >  { 
229-         self . integers_filter_by ( section_name. as_ref ( ) ,  subsection_name,  value_name. as_ref ( ) ,  & mut  |_| { 
230-             true 
231-         } ) 
232+         self . integers_filter_by ( section_name. as_ref ( ) ,  subsection_name,  value_name. as_ref ( ) ,  |_| true ) 
232233    } 
233234
234235    /// Like [`integers_filter_by()`](File::integers_filter_by()), but suitable for statically known `key`s like `remote.origin.url`. 
235236pub  fn  integers_filter ( 
236237        & self , 
237238        key :  impl  AsKey , 
238-         filter :  & mut   MetadataFilter , 
239+         filter :  impl   FnMut ( & Metadata )  ->  bool , 
239240    )  -> Option < Result < Vec < i64 > ,  value:: Error > >  { 
240241        let  key = key. try_as_key ( ) ?; 
241242        self . integers_filter_by ( key. section_name ,  key. subsection_name ,  key. value_name ,  filter) 
@@ -248,7 +249,7 @@ impl File<'_> {
248249        section_name :  impl  AsRef < str > , 
249250        subsection_name :  Option < & BStr > , 
250251        value_name :  impl  AsRef < str > , 
251-         filter :  & mut   MetadataFilter , 
252+         filter :  impl   FnMut ( & Metadata )  ->  bool , 
252253    )  -> Option < Result < Vec < i64 > ,  value:: Error > >  { 
253254        self . raw_values_filter_by ( section_name. as_ref ( ) ,  subsection_name,  value_name. as_ref ( ) ,  filter) 
254255            . ok ( ) 
0 commit comments