aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe-php-shim/src/env.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-27 03:52:05 +0900
committernsfisis <nsfisis@gmail.com>2026-06-27 04:21:34 +0900
commit2b51554ff59d1e5cbf8dd2db65d278b0202a9102 (patch)
treef4d9b0abf4df9b5e363e3bd65511d70e3d5ada00 /crates/shirabe-php-shim/src/env.rs
parentcc07b5abb83a40d678401c335bdc49bb81b72c5f (diff)
downloadphp-shirabe-2b51554ff59d1e5cbf8dd2db65d278b0202a9102.tar.gz
php-shirabe-2b51554ff59d1e5cbf8dd2db65d278b0202a9102.tar.zst
php-shirabe-2b51554ff59d1e5cbf8dd2db65d278b0202a9102.zip
refactor: fix compiler warnings and clippy warnings
Diffstat (limited to 'crates/shirabe-php-shim/src/env.rs')
-rw-r--r--crates/shirabe-php-shim/src/env.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/crates/shirabe-php-shim/src/env.rs b/crates/shirabe-php-shim/src/env.rs
index cf0c659..9043167 100644
--- a/crates/shirabe-php-shim/src/env.rs
+++ b/crates/shirabe-php-shim/src/env.rs
@@ -8,11 +8,21 @@ pub fn getenv<K: AsRef<std::ffi::OsStr>>(key: K) -> Option<std::ffi::OsString> {
std::env::var_os(key)
}
+/// # Safety
+///
+/// Wraps [`std::env::set_var`], which is unsafe: the caller must ensure no other
+/// thread is concurrently reading or writing the process environment for the
+/// duration of this call.
pub unsafe fn putenv<K: AsRef<std::ffi::OsStr>, V: AsRef<std::ffi::OsStr>>(key: K, value: V) {
// TODO: validate key and value format to avoid panic?
unsafe { std::env::set_var(key, value) }
}
+/// # Safety
+///
+/// Wraps [`std::env::remove_var`], which is unsafe: the caller must ensure no other
+/// thread is concurrently reading or writing the process environment for the
+/// duration of this call.
pub unsafe fn putenv_clear<K: AsRef<std::ffi::OsStr>>(key: K) {
// TODO: validate key and value format to avoid panic?
unsafe { std::env::remove_var(key) }