mirror of
				https://github.com/dani-garcia/vaultwarden.git
				synced 2025-10-31 10:18:19 +02:00 
			
		
		
		
	Add more clippy checks for better code/readability
A bit inspired by @paolobarbolini from this commit at lettre https://github.com/lettre/lettre/pull/784 . I added a few more clippy lints here, and fixed the resulted issues. Overall i think this could help in preventing future issues, and maybe even peformance problems. It also makes some code a bit more clear. We could always add more if we want to, i left a few out which i think arn't that huge of an issue. Some like the `unused_async` are nice, which resulted in a few `async` removals. Some others are maybe a bit more estatic, like `string_to_string`, but i think it looks better to use `clone` in those cases instead of `to_string` while they already are a string.
This commit is contained in:
		
							
								
								
									
										14
									
								
								src/util.rs
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								src/util.rs
									
									
									
									
									
								
							| @@ -300,7 +300,7 @@ impl Fairing for BetterLogging { | ||||
| // | ||||
| use std::{ | ||||
|     fs::{self, File}, | ||||
|     io::{Read, Result as IOResult}, | ||||
|     io::Result as IOResult, | ||||
|     path::Path, | ||||
| }; | ||||
|  | ||||
| @@ -309,11 +309,7 @@ pub fn file_exists(path: &str) -> bool { | ||||
| } | ||||
|  | ||||
| pub fn read_file(path: &str) -> IOResult<Vec<u8>> { | ||||
|     let mut contents: Vec<u8> = Vec::new(); | ||||
|  | ||||
|     let mut file = File::open(Path::new(path))?; | ||||
|     file.read_to_end(&mut contents)?; | ||||
|  | ||||
|     let contents = fs::read(Path::new(path))?; | ||||
|     Ok(contents) | ||||
| } | ||||
|  | ||||
| @@ -326,11 +322,7 @@ pub fn write_file(path: &str, content: &[u8]) -> Result<(), crate::error::Error> | ||||
| } | ||||
|  | ||||
| pub fn read_file_string(path: &str) -> IOResult<String> { | ||||
|     let mut contents = String::new(); | ||||
|  | ||||
|     let mut file = File::open(Path::new(path))?; | ||||
|     file.read_to_string(&mut contents)?; | ||||
|  | ||||
|     let contents = fs::read_to_string(Path::new(path))?; | ||||
|     Ok(contents) | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user