@@ -39,7 +39,7 @@ use std::fs::{canonicalize as to_absolute_path, read_dir, write as write_to_file
39
39
use std:: io:: BufReader ;
40
40
use std:: path:: { Path , PathBuf } ;
41
41
42
- use rand:: { seq:: SliceRandom , thread_rng } ;
42
+ use rand:: { rng , seq:: SliceRandom } ;
43
43
use serde:: { Deserialize , Serialize } ;
44
44
use serde_json:: { from_reader as json_from_reader, to_string_pretty as json_to_string} ;
45
45
use serenity:: { builder:: CreateAttachment , builder:: EditProfile , http:: Http } ;
@@ -102,7 +102,12 @@ fn save_current_state(avatars: &Avatars, path_to_data: &Path) {
102
102
)
103
103
} ) ,
104
104
)
105
- . unwrap_or_else ( |e| panic ! ( "Couldn't write data file to {path_to_data:?}. Error message: {e}" ) ) ;
105
+ . unwrap_or_else ( |e| {
106
+ panic ! (
107
+ "Couldn't write data file to {}. Error message: {e}" ,
108
+ path_to_data. display( )
109
+ )
110
+ } ) ;
106
111
}
107
112
108
113
fn get_config_and_data_path ( ) -> Pathes {
@@ -113,7 +118,7 @@ fn get_config_and_data_path() -> Pathes {
113
118
assert ! (
114
119
path_to_config. is_file( ) ,
115
120
"{}" ,
116
- format!( "{path_to_config:? } isn't a file" )
121
+ format!( "{} isn't a file" , path_to_config . display ( ) )
117
122
) ;
118
123
Pathes {
119
124
path_to_config,
@@ -140,7 +145,7 @@ fn get_dir_with_data_and_config() -> PathBuf {
140
145
assert ! (
141
146
& path_to_dir_with_data_and_config. is_dir( ) ,
142
147
"{}" ,
143
- format!( "{path_to_dir_with_data_and_config:? } isn't a directory" )
148
+ format!( "{} isn't a directory" , path_to_dir_with_data_and_config . display ( ) )
144
149
) ;
145
150
path_to_dir_with_data_and_config
146
151
} )
@@ -154,7 +159,7 @@ fn get_current_state(config: &Config, path_to_data: &Path) -> Avatars {
154
159
& config. avatars_dirs ,
155
160
config. should_get_avatars_from_subdirectories ,
156
161
) ;
157
- let mut rng = thread_rng ( ) ;
162
+ let mut rng = rng ( ) ;
158
163
let default = & String :: default ( ) ;
159
164
let current = avatars. current . as_deref ( ) . unwrap_or ( default) ;
160
165
loop {
@@ -269,9 +274,14 @@ where
269
274
|e| {
270
275
panic ! (
271
276
"Couldn't open {:?} file. Error message: {e}" ,
272
- to_absolute_path( path) . unwrap( )
277
+ to_absolute_path( path) . unwrap( ) . display ( )
273
278
)
274
279
} ,
275
280
) ) )
276
- . unwrap_or_else ( |e| panic ! ( "Couldn't parse {path:?} as json. Error message: {e}" ) )
281
+ . unwrap_or_else ( |e| {
282
+ panic ! (
283
+ "Couldn't parse {} as json. Error message: {e}" ,
284
+ path. display( )
285
+ )
286
+ } )
277
287
}
0 commit comments