minor improvments

This commit is contained in:
Aleksandr Trushkin
2024-05-05 22:20:56 +03:00
parent 9d707d19a8
commit 6186436ea8
2 changed files with 8 additions and 8 deletions

View File

@ -14,7 +14,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
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<dyn std::error::Error>> {
}
fn get_value_from_env(key: &str) -> Option<String> {
env::var(key).map_or_else(|_| None, Some)
env::var(key).ok()
}
fn get_value_from_command<I: IntoIterator<Item = S>, S: AsRef<std::ffi::OsStr>>(

View File

@ -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,
}