@@ -34,7 +34,7 @@ impl Config {
3434 /// * `path` - path to the file with the snippets that will be stored in the configuration.
3535 pub fn new ( path : & Path ) -> Result < Self , LazyCoderError > {
3636 if let Ok ( absolute_path) = canonicalize ( path) {
37- debug ! ( "{:?} does exist" , absolute_path ) ;
37+ debug ! ( "{absolute_path :?} does exist" ) ;
3838 let new_config = Config {
3939 file_path : absolute_path. to_str ( ) . unwrap ( ) . to_string ( ) ,
4040 position : 0 ,
@@ -163,21 +163,21 @@ mod tests {
163163 use super :: * ;
164164
165165 thread_local ! {
166- static CANONIZALIZE_ANSWER : Cell <Option <PathBuf >> = Cell :: new( None ) ;
167- static CONFIG_DIR_ANSWER : Cell <Option <PathBuf >> = Cell :: new( None ) ;
168- static CREATE_DIR_OK_ANSWER : Cell <bool > = Cell :: new( true ) ;
169- static CREATE_DIR_ALL_ARG : Cell <Option <PathBuf >> = Cell :: new( None ) ;
170- static PATH_EXISTS_ANSWER : Cell <bool > = Cell :: new( true ) ;
171- static READ_TO_STRING_ANSWER : Cell <Option <String >> = Cell :: new( None ) ;
172- static SNIPPET_PROVIDER_ANSWER : Cell <Option <Box <dyn SnippetProvider >>> = Cell :: new( None ) ;
173- static WRITE_OK_ANSWER : Cell <bool > = Cell :: new( true ) ;
174- static WRITE_ARG_PATH : Cell <Option <PathBuf >> = Cell :: new( None ) ;
175- static WRITE_ARG_CONTENTS : Cell <Option <String >> = Cell :: new( None ) ;
166+ static CANONICALIZE_ANSWER : Cell <Option <PathBuf >> = const { Cell :: new( None ) } ;
167+ static CONFIG_DIR_ANSWER : Cell <Option <PathBuf >> = const { Cell :: new( None ) } ;
168+ static CREATE_DIR_OK_ANSWER : Cell <bool > = const { Cell :: new( true ) } ;
169+ static CREATE_DIR_ALL_ARG : Cell <Option <PathBuf >> = const { Cell :: new( None ) } ;
170+ static PATH_EXISTS_ANSWER : Cell <bool > = const { Cell :: new( true ) } ;
171+ static READ_TO_STRING_ANSWER : Cell <Option <String >> = const { Cell :: new( None ) } ;
172+ static SNIPPET_PROVIDER_ANSWER : Cell <Option <Box <dyn SnippetProvider >>> = const { Cell :: new( None ) } ;
173+ static WRITE_OK_ANSWER : Cell <bool > = const { Cell :: new( true ) } ;
174+ static WRITE_ARG_PATH : Cell <Option <PathBuf >> = const { Cell :: new( None ) } ;
175+ static WRITE_ARG_CONTENTS : Cell <Option <String >> = const { Cell :: new( None ) } ;
176176 }
177177
178178 #[ test]
179179 fn config_new_from_non_existing_path_fails ( ) {
180- CANONIZALIZE_ANSWER . set ( None ) ;
180+ CANONICALIZE_ANSWER . set ( None ) ;
181181
182182 let sut = Config :: new ( Path :: new ( "" ) ) ;
183183
@@ -188,7 +188,7 @@ mod tests {
188188 fn config_new_from_existing_path_is_created ( ) {
189189 let mut path = PathBuf :: new ( ) ;
190190 path. push ( "/tmp" ) ;
191- CANONIZALIZE_ANSWER . set ( Some ( path) ) ;
191+ CANONICALIZE_ANSWER . set ( Some ( path) ) ;
192192 CONFIG_DIR_ANSWER . set ( Some ( PathBuf :: from_str ( "Some path" ) . unwrap ( ) ) ) ;
193193
194194 let sut = Config :: new ( Path :: new ( "/tmp" ) ) ;
@@ -323,8 +323,7 @@ mod tests {
323323
324324 assert ! (
325325 matches!( snippet, Ok ( ref text) if text == "Some snippet" ) ,
326- "Snippet: {:?}" ,
327- snippet
326+ "Snippet: {snippet:?}"
328327 ) ;
329328 path_buf. push ( FILE_NAME ) ;
330329 assert_eq ! ( WRITE_ARG_PATH . take( ) , Some ( path_buf) ) ;
@@ -357,8 +356,7 @@ mod tests {
357356
358357 assert ! (
359358 matches!( snippet, Err ( LazyCoderError :: RunOutOfSnippets ) ) ,
360- "Snippet: {:?}" ,
361- snippet
359+ "Snippet: {snippet:?}"
362360 ) ;
363361 assert_eq ! ( WRITE_ARG_PATH . take( ) , None ) ;
364362 assert_eq ! ( WRITE_ARG_CONTENTS . take( ) , None ) ;
@@ -383,8 +381,7 @@ mod tests {
383381
384382 assert ! (
385383 matches!( snippet, Err ( LazyCoderError :: ConfigDirError ) ) ,
386- "Snippet: {:?}" ,
387- snippet
384+ "Snippet: {snippet:?}"
388385 ) ;
389386 assert_eq ! ( WRITE_ARG_PATH . take( ) , None ) ;
390387 assert_eq ! ( WRITE_ARG_CONTENTS . take( ) , None ) ;
@@ -411,8 +408,7 @@ mod tests {
411408
412409 assert ! (
413410 matches!( snippet, Ok ( ref text) if text == "Some snippet" ) ,
414- "Snippet: {:?}" ,
415- snippet
411+ "Snippet: {snippet:?}"
416412 ) ;
417413 }
418414
@@ -437,8 +433,7 @@ mod tests {
437433
438434 assert ! (
439435 matches!( snippet, Err ( LazyCoderError :: RunOutOfSnippets ) ) ,
440- "Snippet: {:?}" ,
441- snippet
436+ "Snippet: {snippet:?}"
442437 ) ;
443438 }
444439
@@ -515,13 +510,13 @@ mod tests {
515510 use crate :: { lazy_coder_error:: LazyCoderError , snippet_handler:: SnippetProvider } ;
516511
517512 use super :: {
518- CANONIZALIZE_ANSWER , CONFIG_DIR_ANSWER , CREATE_DIR_ALL_ARG , CREATE_DIR_OK_ANSWER ,
513+ CANONICALIZE_ANSWER , CONFIG_DIR_ANSWER , CREATE_DIR_ALL_ARG , CREATE_DIR_OK_ANSWER ,
519514 PATH_EXISTS_ANSWER , READ_TO_STRING_ANSWER , SNIPPET_PROVIDER_ANSWER , WRITE_ARG_CONTENTS ,
520515 WRITE_ARG_PATH , WRITE_OK_ANSWER ,
521516 } ;
522517
523518 pub fn canonicalize < P : AsRef < Path > > ( _path : P ) -> io:: Result < PathBuf > {
524- match CANONIZALIZE_ANSWER . take ( ) {
519+ match CANONICALIZE_ANSWER . take ( ) {
525520 Some ( path_buf) => Ok ( path_buf) ,
526521 None => Err ( io:: Error :: other ( "Some error" ) ) ,
527522 }
0 commit comments