Skip to content

Commit e794954

Browse files
authored
Update rust-toolchain (#234)
* Update rust-toolchain * Fix clippy errors * Format * Disable rust 2015 * Format * Format
1 parent d4d97d8 commit e794954

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,4 @@ jobs:
8686
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8787
VALIDATE_EDITORCONFIG: false
8888
VALIDATE_RUST_CLIPPY: false
89+
VALIDATE_RUST_2015: false

rust-toolchain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[toolchain]
2-
channel = "1.86.0"
2+
channel = "1.87.0"
33
components = ["rustfmt", "clippy"]
44
targets = ["x86_64-unknown-linux-gnu"]

src/main.rs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ use std::fs::{canonicalize as to_absolute_path, read_dir, write as write_to_file
3939
use std::io::BufReader;
4040
use std::path::{Path, PathBuf};
4141

42-
use rand::{seq::SliceRandom, thread_rng};
42+
use rand::{rng, seq::SliceRandom};
4343
use serde::{Deserialize, Serialize};
4444
use serde_json::{from_reader as json_from_reader, to_string_pretty as json_to_string};
4545
use serenity::{builder::CreateAttachment, builder::EditProfile, http::Http};
@@ -102,7 +102,12 @@ fn save_current_state(avatars: &Avatars, path_to_data: &Path) {
102102
)
103103
}),
104104
)
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+
});
106111
}
107112

108113
fn get_config_and_data_path() -> Pathes {
@@ -113,7 +118,7 @@ fn get_config_and_data_path() -> Pathes {
113118
assert!(
114119
path_to_config.is_file(),
115120
"{}",
116-
format!("{path_to_config:?} isn't a file")
121+
format!("{} isn't a file", path_to_config.display())
117122
);
118123
Pathes {
119124
path_to_config,
@@ -140,7 +145,7 @@ fn get_dir_with_data_and_config() -> PathBuf {
140145
assert!(
141146
&path_to_dir_with_data_and_config.is_dir(),
142147
"{}",
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())
144149
);
145150
path_to_dir_with_data_and_config
146151
} )
@@ -154,7 +159,7 @@ fn get_current_state(config: &Config, path_to_data: &Path) -> Avatars {
154159
&config.avatars_dirs,
155160
config.should_get_avatars_from_subdirectories,
156161
);
157-
let mut rng = thread_rng();
162+
let mut rng = rng();
158163
let default = &String::default();
159164
let current = avatars.current.as_deref().unwrap_or(default);
160165
loop {
@@ -269,9 +274,14 @@ where
269274
|e| {
270275
panic!(
271276
"Couldn't open {:?} file. Error message: {e}",
272-
to_absolute_path(path).unwrap()
277+
to_absolute_path(path).unwrap().display()
273278
)
274279
},
275280
)))
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+
})
277287
}

0 commit comments

Comments
 (0)