From 6186436ea8231d4f9e5f875e9e9132b99bd70799 Mon Sep 17 00:00:00 2001 From: Aleksandr Trushkin Date: Sun, 5 May 2024 22:20:56 +0300 Subject: [PATCH] minor improvments --- build.rs | 4 ++-- src/main.rs | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/build.rs b/build.rs index 7455a7a..27dd2e3 100644 --- a/build.rs +++ b/build.rs @@ -14,7 +14,7 @@ fn main() -> Result<(), Box> { println!("cargo:rerun-if-env-changed=GIT_REVISION"); if let Ok(data) = std::fs::read_to_string(".env") { - data.split('\n').into_iter().for_each(|v| { + data.split('\n').for_each(|v| { let kv: Vec<&str> = v.split('=').collect(); if kv.len() != 2 { return; @@ -34,7 +34,7 @@ fn main() -> Result<(), Box> { } fn get_value_from_env(key: &str) -> Option { - env::var(key).map_or_else(|_| None, Some) + env::var(key).ok() } fn get_value_from_command, S: AsRef>( diff --git a/src/main.rs b/src/main.rs index 5f298cf..e4b4879 100644 --- a/src/main.rs +++ b/src/main.rs @@ -70,7 +70,7 @@ async fn run() -> anyhow::Result<()> { let climate_client = climate::Client::new(&settings.climate_dsn); let self_temp_client = { - let splitted: Vec<&str> = settings.hosttemp_cmd.split(' ').into_iter().collect(); + let splitted: Vec<&str> = settings.hosttemp_cmd.split(' ').collect(); let (cmd, arg) = (splitted[0], splitted[1]); climate::SelfTemperature::new(cmd, arg) @@ -263,14 +263,14 @@ struct Climate { #[derive(BotCommands, Debug, Clone, PartialEq, Eq)] #[command(description = "These commands are supported:")] enum Command { - #[command(rename="help", description = "display this text.")] + #[command(rename = "help", description = "display this text.")] Help, - #[command(rename="roomtemp", description = "temperature of your room.")] + #[command(rename = "roomtemp", description = "temperature of your room.")] RoomTemperature, - #[command(rename="hosttemp", description = "temperature of raspberry.")] + #[command(rename = "hosttemp", description = "temperature of raspberry.")] HostTemperature, - #[command(rename="version", description = "prints current version.")] + #[command(rename = "version", description = "prints current version.")] VersionRequest, - #[command(rename="chatid", description = "prints current chat id.")] + #[command(rename = "chatid", description = "prints current chat id.")] ChatID, }