Skip to content

Commit 2fd7dd7

Browse files
committed
[rust] Minor refactoring according to linter warning
1 parent 47f993f commit 2fd7dd7

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

rust/src/files.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use std::error::Error;
1919
use std::fs;
2020
use std::fs::File;
2121
use std::io;
22-
use std::path::MAIN_SEPARATOR;
22+
2323
use std::path::{Path, PathBuf};
2424

2525
use crate::config::OS;
@@ -131,7 +131,7 @@ pub fn unzip(file: File, target: &Path, log: &Logger) -> Result<(), Box<dyn Erro
131131
));
132132
create_parent_path_if_not_exists(target);
133133
if !target.exists() {
134-
let mut outfile = File::create(&target)?;
134+
let mut outfile = File::create(target)?;
135135

136136
// Set permissions in Unix-like systems
137137
#[cfg(unix)]
@@ -152,7 +152,7 @@ pub fn unzip(file: File, target: &Path, log: &Logger) -> Result<(), Box<dyn Erro
152152
pub fn compose_cache_folder() -> PathBuf {
153153
if let Some(base_dirs) = BaseDirs::new() {
154154
return Path::new(base_dirs.home_dir())
155-
.join(String::from(CACHE_FOLDER).replace('/', &MAIN_SEPARATOR.to_string()));
155+
.join(String::from(CACHE_FOLDER).replace('/', std::path::MAIN_SEPARATOR_STR));
156156
}
157157
PathBuf::new()
158158
}

rust/src/logger.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,43 +29,42 @@ use std::io::Write;
2929
use std::ops::Deref;
3030
use Color::{Blue, Cyan, Green, Red, Yellow};
3131

32+
#[derive(Default)]
3233
enum OutputType {
34+
#[default]
3335
Logger,
3436
Json,
3537
Shell,
3638
}
3739

40+
#[derive(Default)]
3841
pub struct Logger {
3942
debug: bool,
4043
trace: bool,
4144
output: OutputType,
4245
json: RefCell<JsonOutput>,
4346
}
4447

45-
#[derive(Serialize, Deserialize)]
48+
#[derive(Default, Serialize, Deserialize)]
4649
pub struct Logs {
4750
pub level: String,
4851
pub timestamp: u64,
4952
pub message: String,
5053
}
5154

52-
#[derive(Serialize, Deserialize)]
55+
#[derive(Default, Serialize, Deserialize)]
5356
pub struct Result {
5457
pub code: i32,
5558
pub message: String,
5659
}
5760

58-
#[derive(Serialize, Deserialize)]
61+
#[derive(Default, Serialize, Deserialize)]
5962
pub struct JsonOutput {
6063
pub logs: Vec<Logs>,
6164
pub result: Result,
6265
}
6366

6467
impl Logger {
65-
pub fn default() -> Self {
66-
Logger::create("", false, false)
67-
}
68-
6968
pub fn create(output: &str, debug: bool, trace: bool) -> Self {
7069
let output_type;
7170
if output.eq_ignore_ascii_case("json") {

0 commit comments

Comments
 (0)