From d9eecf1f5f143a35f0ac1653149287f6ac442c23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodolphe=20Br=C3=A9ard?= Date: Mon, 27 Mar 2023 22:46:50 +0200 Subject: [PATCH] Refactor the build script --- build.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/build.rs b/build.rs index 78a4e6e..9b6dd22 100644 --- a/build.rs +++ b/build.rs @@ -1,9 +1,13 @@ use std::env; -const DEFAULT_VARLIBDIR: &str = "/var/lib/"; +const VARLIBDIR_NAME: &str = "VARLIBDIR"; +const VARLIBDIR_VALUE_DEFAULT: &str = "/var/lib/"; fn main() { - if let Err(_) = env::var("VARLIBDIR") { - println!("cargo:rustc-env={}={}", "VARLIBDIR", DEFAULT_VARLIBDIR); + if env::var(VARLIBDIR_NAME).is_err() { + println!( + "cargo:rustc-env={}={}", + VARLIBDIR_NAME, VARLIBDIR_VALUE_DEFAULT + ); } }