Clippy
This commit is contained in:
parent
1d131e790c
commit
b7b938c564
4 changed files with 17 additions and 14 deletions
|
@ -1,3 +1,4 @@
|
|||
use std::fmt::{Display, Write};
|
||||
use diesel::{
|
||||
backend::Backend, deserialize::{FromSql, FromSqlRow}, serialize::ToSql, sql_types::Text, sqlite::Sqlite
|
||||
};
|
||||
|
@ -6,16 +7,18 @@ use diesel::{
|
|||
#[repr(transparent)]
|
||||
pub struct List<V: std::fmt::Debug>(pub Vec<V>);
|
||||
|
||||
impl ToString for List<String> {
|
||||
fn to_string(&self) -> String {
|
||||
"[".to_owned()
|
||||
+ &self
|
||||
.0
|
||||
.iter()
|
||||
.map(|v| "\"".to_owned() + &v.replace("\"", "\\\"") + "\"")
|
||||
.collect::<Vec<String>>()
|
||||
.join(",")
|
||||
+ "]"
|
||||
impl Display for List<String> {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.write_char('[')?;
|
||||
f.write_str(
|
||||
&self
|
||||
.0
|
||||
.iter()
|
||||
.map(|v| "\"".to_owned() + &v.replace("\"", "\\\"") + "\"")
|
||||
.collect::<Vec<String>>()
|
||||
.join(",")
|
||||
)?;
|
||||
f.write_char(']')
|
||||
}
|
||||
}
|
||||
|
|
@ -20,7 +20,7 @@ use crate::env::database_url;
|
|||
|
||||
pub mod models;
|
||||
pub mod schema;
|
||||
pub mod types;
|
||||
pub mod list;
|
||||
|
||||
pub fn establish_connection() -> SqliteConnection {
|
||||
let url = database_url();
|
||||
|
|
|
@ -18,7 +18,7 @@ use chrono::NaiveDateTime;
|
|||
use diesel::prelude::*;
|
||||
|
||||
use crate::database::schema;
|
||||
use crate::database::types::List;
|
||||
use crate::database::list::List;
|
||||
|
||||
#[derive(Queryable, Selectable)]
|
||||
#[diesel(table_name = schema::date_entries)]
|
||||
|
|
|
@ -18,7 +18,7 @@ use std::env;
|
|||
use std::sync::OnceLock;
|
||||
use std::time::Duration;
|
||||
|
||||
const REQUIRED_ENV_VARIABLES: [&'static str; 4] = [
|
||||
const REQUIRED_ENV_VARIABLES: [&str; 4] = [
|
||||
"IDENTITY_API_JWT_SECRET",
|
||||
"IDENTITY_API_ASSET_API_ENDPOINT",
|
||||
"IDENTITY_API_JWT_ALG",
|
||||
|
@ -32,7 +32,7 @@ pub enum LoadEnvError {
|
|||
}
|
||||
|
||||
pub fn load_env() -> Result<(), LoadEnvError> {
|
||||
dotenvy::dotenv().map_err(|e| LoadEnvError::DotenvyError(e))?;
|
||||
dotenvy::dotenv().map_err(LoadEnvError::DotenvyError)?;
|
||||
|
||||
for key in REQUIRED_ENV_VARIABLES {
|
||||
if env::var(key).is_err() {
|
||||
|
|
Loading…
Reference in a new issue