ultimate_common/
runtime.rs

1use std::{
2  env::{self, VarError},
3  path::PathBuf,
4};
5
6pub static CARGO_MANIFEST_DIR: &str = env!("CARGO_MANIFEST_DIR");
7
8pub type Result<T> = core::result::Result<T, VarError>;
9
10#[inline]
11pub fn cargo_manifest_dir() -> Result<PathBuf> {
12  from_env("CARGO_MANIFEST_DIR").map(PathBuf::from)
13}
14
15#[inline]
16pub fn cargo_pkg_name() -> Result<String> {
17  from_env("CARGO_PKG_NAME")
18}
19
20#[inline]
21pub fn cargo_pkg_version() -> Result<String> {
22  from_env("CARGO_PKG_VERSION")
23}
24
25#[inline]
26fn from_env(name: &str) -> Result<String> {
27  env::var(name)
28}