@@ -131,111 +131,113 @@ mod interpolate {
131131mod optional_prefix {
132132 use std:: borrow:: Cow ;
133133
134- use bstr:: ByteSlice ;
135134 use crate :: { b, cow_str} ;
135+ use bstr:: ByteSlice ;
136136
137137 #[ test]
138138 fn path_without_optional_prefix_is_not_optional ( ) {
139139 let path = gix_config_value:: Path :: from ( Cow :: Borrowed ( b ( "/some/path" ) ) ) ;
140- assert ! ( !path. is_optional( ) , "path without prefix should not be optional" ) ;
140+ assert ! ( !path. is_optional, "path without prefix should not be optional" ) ;
141141 assert_eq ! ( path. value. as_ref( ) , b"/some/path" ) ;
142142 }
143143
144144 #[ test]
145145 fn path_with_optional_prefix_is_optional ( ) {
146146 let path = gix_config_value:: Path :: from ( cow_str ( ":(optional)/some/path" ) ) ;
147- assert ! ( path. is_optional( ) , "path with :(optional) prefix should be optional" ) ;
147+ assert ! ( path. is_optional, "path with :(optional) prefix should be optional" ) ;
148148 assert_eq ! ( path. value. as_ref( ) , b"/some/path" , "prefix should be stripped" ) ;
149149 }
150150
151151 #[ test]
152152 fn optional_prefix_with_relative_path ( ) {
153153 let path = gix_config_value:: Path :: from ( cow_str ( ":(optional)relative/path" ) ) ;
154- assert ! ( path. is_optional( ) ) ;
154+ assert ! ( path. is_optional) ;
155155 assert_eq ! ( path. value. as_ref( ) , b"relative/path" ) ;
156156 }
157157
158158 #[ test]
159159 fn optional_prefix_with_tilde_expansion ( ) {
160160 let path = gix_config_value:: Path :: from ( cow_str ( ":(optional)~/config/file" ) ) ;
161- assert ! ( path. is_optional( ) ) ;
162- assert_eq ! ( path. value. as_ref( ) , b"~/config/file" , "tilde should be preserved for interpolation" ) ;
161+ assert ! ( path. is_optional) ;
162+ assert_eq ! (
163+ path. value. as_ref( ) ,
164+ b"~/config/file" ,
165+ "tilde should be preserved for interpolation"
166+ ) ;
163167 }
164168
165169 #[ test]
166170 fn optional_prefix_with_prefix_substitution ( ) {
167171 let path = gix_config_value:: Path :: from ( cow_str ( ":(optional)%(prefix)/share/git" ) ) ;
168- assert ! ( path. is_optional( ) ) ;
169- assert_eq ! ( path. value. as_ref( ) , b"%(prefix)/share/git" , "prefix should be preserved for interpolation" ) ;
172+ assert ! ( path. is_optional) ;
173+ assert_eq ! (
174+ path. value. as_ref( ) ,
175+ b"%(prefix)/share/git" ,
176+ "prefix should be preserved for interpolation"
177+ ) ;
170178 }
171179
172180 #[ test]
173181 fn optional_prefix_with_windows_path ( ) {
174182 let path = gix_config_value:: Path :: from ( cow_str ( r":(optional)C:\Users\file" ) ) ;
175- assert ! ( path. is_optional( ) ) ;
183+ assert ! ( path. is_optional) ;
176184 assert_eq ! ( path. value. as_ref( ) , br"C:\Users\file" ) ;
177185 }
178186
179187 #[ test]
180188 fn optional_prefix_followed_by_empty_path ( ) {
181189 let path = gix_config_value:: Path :: from ( cow_str ( ":(optional)" ) ) ;
182- assert ! ( path. is_optional( ) ) ;
190+ assert ! ( path. is_optional) ;
183191 assert_eq ! ( path. value. as_ref( ) , b"" , "empty path after prefix is valid" ) ;
184192 }
185193
186194 #[ test]
187195 fn partial_optional_string_is_not_treated_as_prefix ( ) {
188196 let path = gix_config_value:: Path :: from ( cow_str ( ":(opt)ional/path" ) ) ;
189- assert ! ( !path. is_optional( ) , "incomplete prefix should not be treated as optional marker" ) ;
197+ assert ! (
198+ !path. is_optional,
199+ "incomplete prefix should not be treated as optional marker"
200+ ) ;
190201 assert_eq ! ( path. value. as_ref( ) , b":(opt)ional/path" ) ;
191202 }
192203
193204 #[ test]
194205 fn optional_prefix_case_sensitive ( ) {
195206 let path = gix_config_value:: Path :: from ( cow_str ( ":(OPTIONAL)/some/path" ) ) ;
196- assert ! ( !path. is_optional( ) , "prefix should be case-sensitive" ) ;
207+ assert ! ( !path. is_optional, "prefix should be case-sensitive" ) ;
197208 assert_eq ! ( path. value. as_ref( ) , b":(OPTIONAL)/some/path" ) ;
198209 }
199210
200211 #[ test]
201212 fn optional_prefix_with_spaces ( ) {
202213 let path = gix_config_value:: Path :: from ( cow_str ( ":(optional) /path/with/space" ) ) ;
203- assert ! ( path. is_optional( ) ) ;
204- assert_eq ! ( path. value. as_ref( ) , b" /path/with/space" , "space after prefix should be preserved" ) ;
205- }
206-
207- #[ test]
208- fn interpolate_preserves_optional_flag ( ) -> crate :: Result {
209- use gix_config_value:: path;
210-
211- let path = gix_config_value:: Path :: from ( cow_str ( ":(optional)/absolute/path" ) ) ;
212- assert ! ( path. is_optional( ) ) ;
213-
214- let interpolated = path. interpolate ( path:: interpolate:: Context :: default ( ) ) ?;
215- assert_eq ! ( interpolated. as_ref( ) , std:: path:: Path :: new( "/absolute/path" ) ) ;
216-
217- Ok ( ( ) )
214+ assert ! ( path. is_optional) ;
215+ assert_eq ! (
216+ path. value. as_ref( ) ,
217+ b" /path/with/space" ,
218+ "space after prefix should be preserved"
219+ ) ;
218220 }
219221
220222 #[ test]
221223 fn borrowed_path_stays_borrowed_after_prefix_stripping ( ) {
222224 // Verify that we don't unnecessarily allocate when stripping the prefix from borrowed data
223225 let borrowed_input: & [ u8 ] = b":(optional)/some/path" ;
224226 let path = gix_config_value:: Path :: from ( Cow :: Borrowed ( borrowed_input. as_bstr ( ) ) ) ;
225-
226- assert ! ( path. is_optional( ) ) ;
227+
228+ assert ! ( path. is_optional) ;
227229 assert_eq ! ( path. value. as_ref( ) , b"/some/path" ) ;
228230 // Verify it's still borrowed (no unnecessary allocation)
229231 assert ! ( matches!( path. value, Cow :: Borrowed ( _) ) ) ;
230232 }
231233
232234 #[ test]
233235 fn owned_path_stays_owned_after_prefix_stripping ( ) {
234- // Verify that owned data remains owned after prefix stripping (but efficiently)
236+ // Verify that owned data remains owned after prefix stripping
235237 let owned_input = bstr:: BString :: from ( ":(optional)/some/path" ) ;
236238 let path = gix_config_value:: Path :: from ( Cow :: Owned ( owned_input) ) ;
237-
238- assert ! ( path. is_optional( ) ) ;
239+
240+ assert ! ( path. is_optional) ;
239241 assert_eq ! ( path. value. as_ref( ) , b"/some/path" ) ;
240242 // Verify it's still owned
241243 assert ! ( matches!( path. value, Cow :: Owned ( _) ) ) ;
0 commit comments