1 //! Inspection and manipulation of the process's environment.
3 //! This module contains functions to inspect various aspects such as
4 //! environment variables, process arguments, the current directory, and various
5 //! other important directories.
7 //! There are several functions and structs in this module that have a
8 //! counterpart ending in `os`. Those ending in `os` will return an [`OsString`]
9 //! and those without will return a [`String`].
11 #![stable(feature = "env", since = "1.0.0")]
16 use crate::error::Error;
17 use crate::ffi::{OsStr, OsString};
20 use crate::path::{Path, PathBuf};
22 use crate::sys::os as os_imp;
24 /// Returns the current working directory as a [`PathBuf`].
28 /// Returns an [`Err`] if the current working directory value is invalid.
31 /// * Current directory does not exist.
32 /// * There are insufficient permissions to access the current directory.
39 /// fn main() -> std::io::Result<()> {
40 /// let path = env::current_dir()?;
41 /// println!("The current directory is {}", path.display());
45 #[stable(feature = "env", since = "1.0.0")]
46 pub fn current_dir() -> io::Result<PathBuf> {
50 /// Changes the current working directory to the specified path.
52 /// Returns an [`Err`] if the operation fails.
58 /// use std::path::Path;
60 /// let root = Path::new("/");
61 /// assert!(env::set_current_dir(&root).is_ok());
62 /// println!("Successfully changed working directory to {}!", root.display());
64 #[doc(alias = "chdir")]
65 #[stable(feature = "env", since = "1.0.0")]
66 pub fn set_current_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
67 os_imp::chdir(path.as_ref())
70 /// An iterator over a snapshot of the environment variables of this process.
72 /// This structure is created by [`env::vars()`]. See its documentation for more.
74 /// [`env::vars()`]: vars
75 #[stable(feature = "env", since = "1.0.0")]
80 /// An iterator over a snapshot of the environment variables of this process.
82 /// This structure is created by [`env::vars_os()`]. See its documentation for more.
84 /// [`env::vars_os()`]: vars_os
85 #[stable(feature = "env", since = "1.0.0")]
90 /// Returns an iterator of (variable, value) pairs of strings, for all the
91 /// environment variables of the current process.
93 /// The returned iterator contains a snapshot of the process's environment
94 /// variables at the time of this invocation. Modifications to environment
95 /// variables afterwards will not be reflected in the returned iterator.
99 /// While iterating, the returned iterator will panic if any key or value in the
100 /// environment is not valid unicode. If this is not desired, consider using
101 /// [`env::vars_os()`].
108 /// // We will iterate through the references to the element returned by
110 /// for (key, value) in env::vars() {
111 /// println!("{}: {}", key, value);
115 /// [`env::vars_os()`]: vars_os
117 #[stable(feature = "env", since = "1.0.0")]
118 pub fn vars() -> Vars {
119 Vars { inner: vars_os() }
122 /// Returns an iterator of (variable, value) pairs of OS strings, for all the
123 /// environment variables of the current process.
125 /// The returned iterator contains a snapshot of the process's environment
126 /// variables at the time of this invocation. Modifications to environment
127 /// variables afterwards will not be reflected in the returned iterator.
129 /// Note that the returned iterator will not check if the environment variables
130 /// are valid Unicode. If you want to panic on invalid UTF-8,
131 /// use the [`vars`] function instead.
138 /// // We will iterate through the references to the element returned by
139 /// // env::vars_os();
140 /// for (key, value) in env::vars_os() {
141 /// println!("{:?}: {:?}", key, value);
145 #[stable(feature = "env", since = "1.0.0")]
146 pub fn vars_os() -> VarsOs {
147 VarsOs { inner: os_imp::env() }
150 #[stable(feature = "env", since = "1.0.0")]
151 impl Iterator for Vars {
152 type Item = (String, String);
153 fn next(&mut self) -> Option<(String, String)> {
154 self.inner.next().map(|(a, b)| (a.into_string().unwrap(), b.into_string().unwrap()))
156 fn size_hint(&self) -> (usize, Option<usize>) {
157 self.inner.size_hint()
161 #[stable(feature = "std_debug", since = "1.16.0")]
162 impl fmt::Debug for Vars {
163 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
164 f.debug_struct("Vars").finish_non_exhaustive()
168 #[stable(feature = "env", since = "1.0.0")]
169 impl Iterator for VarsOs {
170 type Item = (OsString, OsString);
171 fn next(&mut self) -> Option<(OsString, OsString)> {
174 fn size_hint(&self) -> (usize, Option<usize>) {
175 self.inner.size_hint()
179 #[stable(feature = "std_debug", since = "1.16.0")]
180 impl fmt::Debug for VarsOs {
181 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
182 f.debug_struct("VarOs").finish_non_exhaustive()
186 /// Fetches the environment variable `key` from the current process.
190 /// This function will return an error if the environment variable isn't set.
192 /// This function may return an error if the environment variable's name contains
193 /// the equal sign character (`=`) or the NUL character.
195 /// This function will return an error if the environment variable's value is
196 /// not valid Unicode. If this is not desired, consider using [`var_os`].
203 /// let key = "HOME";
204 /// match env::var(key) {
205 /// Ok(val) => println!("{}: {:?}", key, val),
206 /// Err(e) => println!("couldn't interpret {}: {}", key, e),
209 #[stable(feature = "env", since = "1.0.0")]
210 pub fn var<K: AsRef<OsStr>>(key: K) -> Result<String, VarError> {
214 fn _var(key: &OsStr) -> Result<String, VarError> {
216 Some(s) => s.into_string().map_err(VarError::NotUnicode),
217 None => Err(VarError::NotPresent),
221 /// Fetches the environment variable `key` from the current process, returning
222 /// [`None`] if the variable isn't set or there's another error.
224 /// Note that the method will not check if the environment variable
225 /// is valid Unicode. If you want to have an error on invalid UTF-8,
226 /// use the [`var`] function instead.
230 /// This function returns an error if the environment variable isn't set.
232 /// This function may return an error if the environment variable's name contains
233 /// the equal sign character (`=`) or the NUL character.
235 /// This function may return an error if the environment variable's value contains
236 /// the NUL character.
243 /// let key = "HOME";
244 /// match env::var_os(key) {
245 /// Some(val) => println!("{}: {:?}", key, val),
246 /// None => println!("{} is not defined in the environment.", key)
250 #[stable(feature = "env", since = "1.0.0")]
251 pub fn var_os<K: AsRef<OsStr>>(key: K) -> Option<OsString> {
252 _var_os(key.as_ref())
255 fn _var_os(key: &OsStr) -> Option<OsString> {
259 /// The error type for operations interacting with environment variables.
260 /// Possibly returned from [`env::var()`].
262 /// [`env::var()`]: var
263 #[derive(Debug, PartialEq, Eq, Clone)]
264 #[stable(feature = "env", since = "1.0.0")]
266 /// The specified environment variable was not present in the current
267 /// process's environment.
268 #[stable(feature = "env", since = "1.0.0")]
271 /// The specified environment variable was found, but it did not contain
272 /// valid unicode data. The found data is returned as a payload of this
274 #[stable(feature = "env", since = "1.0.0")]
275 NotUnicode(#[stable(feature = "env", since = "1.0.0")] OsString),
278 #[stable(feature = "env", since = "1.0.0")]
279 impl fmt::Display for VarError {
280 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
282 VarError::NotPresent => write!(f, "environment variable not found"),
283 VarError::NotUnicode(ref s) => {
284 write!(f, "environment variable was not valid unicode: {:?}", s)
290 #[stable(feature = "env", since = "1.0.0")]
291 impl Error for VarError {
293 fn description(&self) -> &str {
295 VarError::NotPresent => "environment variable not found",
296 VarError::NotUnicode(..) => "environment variable was not valid unicode",
301 /// Sets the environment variable `key` to the value `value` for the currently running
304 /// Note that while concurrent access to environment variables is safe in Rust,
305 /// some platforms only expose inherently unsafe non-threadsafe APIs for
306 /// inspecting the environment. As a result, extra care needs to be taken when
307 /// auditing calls to unsafe external FFI functions to ensure that any external
308 /// environment accesses are properly synchronized with accesses in Rust.
310 /// Discussion of this unsafety on Unix may be found in:
312 /// - [Austin Group Bugzilla](https://austingroupbugs.net/view.php?id=188)
313 /// - [GNU C library Bugzilla](https://sourceware.org/bugzilla/show_bug.cgi?id=15607#c2)
317 /// This function may panic if `key` is empty, contains an ASCII equals sign `'='`
318 /// or the NUL character `'\0'`, or when `value` contains the NUL character.
326 /// env::set_var(key, "VALUE");
327 /// assert_eq!(env::var(key), Ok("VALUE".to_string()));
329 #[stable(feature = "env", since = "1.0.0")]
330 pub fn set_var<K: AsRef<OsStr>, V: AsRef<OsStr>>(key: K, value: V) {
331 _set_var(key.as_ref(), value.as_ref())
334 fn _set_var(key: &OsStr, value: &OsStr) {
335 os_imp::setenv(key, value).unwrap_or_else(|e| {
336 panic!("failed to set environment variable `{:?}` to `{:?}`: {}", key, value, e)
340 /// Removes an environment variable from the environment of the currently running process.
342 /// Note that while concurrent access to environment variables is safe in Rust,
343 /// some platforms only expose inherently unsafe non-threadsafe APIs for
344 /// inspecting the environment. As a result extra care needs to be taken when
345 /// auditing calls to unsafe external FFI functions to ensure that any external
346 /// environment accesses are properly synchronized with accesses in Rust.
348 /// Discussion of this unsafety on Unix may be found in:
350 /// - [Austin Group Bugzilla](https://austingroupbugs.net/view.php?id=188)
351 /// - [GNU C library Bugzilla](https://sourceware.org/bugzilla/show_bug.cgi?id=15607#c2)
355 /// This function may panic if `key` is empty, contains an ASCII equals sign
356 /// `'='` or the NUL character `'\0'`, or when the value contains the NUL
365 /// env::set_var(key, "VALUE");
366 /// assert_eq!(env::var(key), Ok("VALUE".to_string()));
368 /// env::remove_var(key);
369 /// assert!(env::var(key).is_err());
371 #[stable(feature = "env", since = "1.0.0")]
372 pub fn remove_var<K: AsRef<OsStr>>(key: K) {
373 _remove_var(key.as_ref())
376 fn _remove_var(key: &OsStr) {
377 os_imp::unsetenv(key)
378 .unwrap_or_else(|e| panic!("failed to remove environment variable `{:?}`: {}", key, e))
381 /// An iterator that splits an environment variable into paths according to
382 /// platform-specific conventions.
384 /// The iterator element type is [`PathBuf`].
386 /// This structure is created by [`env::split_paths()`]. See its
387 /// documentation for more.
389 /// [`env::split_paths()`]: split_paths
390 #[must_use = "iterators are lazy and do nothing unless consumed"]
391 #[stable(feature = "env", since = "1.0.0")]
392 pub struct SplitPaths<'a> {
393 inner: os_imp::SplitPaths<'a>,
396 /// Parses input according to platform conventions for the `PATH`
397 /// environment variable.
399 /// Returns an iterator over the paths contained in `unparsed`. The iterator
400 /// element type is [`PathBuf`].
407 /// let key = "PATH";
408 /// match env::var_os(key) {
410 /// for path in env::split_paths(&paths) {
411 /// println!("'{}'", path.display());
414 /// None => println!("{} is not defined in the environment.", key)
417 #[stable(feature = "env", since = "1.0.0")]
418 pub fn split_paths<T: AsRef<OsStr> + ?Sized>(unparsed: &T) -> SplitPaths<'_> {
419 SplitPaths { inner: os_imp::split_paths(unparsed.as_ref()) }
422 #[stable(feature = "env", since = "1.0.0")]
423 impl<'a> Iterator for SplitPaths<'a> {
425 fn next(&mut self) -> Option<PathBuf> {
428 fn size_hint(&self) -> (usize, Option<usize>) {
429 self.inner.size_hint()
433 #[stable(feature = "std_debug", since = "1.16.0")]
434 impl fmt::Debug for SplitPaths<'_> {
435 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
436 f.debug_struct("SplitPaths").finish_non_exhaustive()
440 /// The error type for operations on the `PATH` variable. Possibly returned from
441 /// [`env::join_paths()`].
443 /// [`env::join_paths()`]: join_paths
445 #[stable(feature = "env", since = "1.0.0")]
446 pub struct JoinPathsError {
447 inner: os_imp::JoinPathsError,
450 /// Joins a collection of [`Path`]s appropriately for the `PATH`
451 /// environment variable.
455 /// Returns an [`Err`] (containing an error message) if one of the input
456 /// [`Path`]s contains an invalid character for constructing the `PATH`
457 /// variable (a double quote on Windows or a colon on Unix).
461 /// Joining paths on a Unix-like platform:
465 /// use std::ffi::OsString;
466 /// use std::path::Path;
468 /// fn main() -> Result<(), env::JoinPathsError> {
469 /// # if cfg!(unix) {
470 /// let paths = [Path::new("/bin"), Path::new("/usr/bin")];
471 /// let path_os_string = env::join_paths(paths.iter())?;
472 /// assert_eq!(path_os_string, OsString::from("/bin:/usr/bin"));
478 /// Joining a path containing a colon on a Unix-like platform results in an
482 /// # if cfg!(unix) {
484 /// use std::path::Path;
486 /// let paths = [Path::new("/bin"), Path::new("/usr/bi:n")];
487 /// assert!(env::join_paths(paths.iter()).is_err());
491 /// Using `env::join_paths()` with [`env::split_paths()`] to append an item to
492 /// the `PATH` environment variable:
496 /// use std::path::PathBuf;
498 /// fn main() -> Result<(), env::JoinPathsError> {
499 /// if let Some(path) = env::var_os("PATH") {
500 /// let mut paths = env::split_paths(&path).collect::<Vec<_>>();
501 /// paths.push(PathBuf::from("/home/xyz/bin"));
502 /// let new_path = env::join_paths(paths)?;
503 /// env::set_var("PATH", &new_path);
510 /// [`env::split_paths()`]: split_paths
511 #[stable(feature = "env", since = "1.0.0")]
512 pub fn join_paths<I, T>(paths: I) -> Result<OsString, JoinPathsError>
514 I: IntoIterator<Item = T>,
517 os_imp::join_paths(paths.into_iter()).map_err(|e| JoinPathsError { inner: e })
520 #[stable(feature = "env", since = "1.0.0")]
521 impl fmt::Display for JoinPathsError {
522 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
527 #[stable(feature = "env", since = "1.0.0")]
528 impl Error for JoinPathsError {
529 #[allow(deprecated, deprecated_in_future)]
530 fn description(&self) -> &str {
531 self.inner.description()
535 /// Returns the path of the current user's home directory if known.
539 /// - Returns the value of the 'HOME' environment variable if it is set
540 /// (including to an empty string).
541 /// - Otherwise, it tries to determine the home directory by invoking the `getpwuid_r` function
542 /// using the UID of the current user. An empty home directory field returned from the
543 /// `getpwuid_r` function is considered to be a valid value.
544 /// - Returns `None` if the current user has no entry in the /etc/passwd file.
548 /// - Returns the value of the 'HOME' environment variable if it is set
549 /// (including to an empty string).
550 /// - Otherwise, returns the value of the 'USERPROFILE' environment variable if it is set
551 /// (including to an empty string).
552 /// - If both do not exist, [`GetUserProfileDirectory`][msdn] is used to return the path.
554 /// [msdn]: https://docs.microsoft.com/en-us/windows/win32/api/userenv/nf-userenv-getuserprofiledirectorya
561 /// match env::home_dir() {
562 /// Some(path) => println!("Your home directory, probably: {}", path.display()),
563 /// None => println!("Impossible to get your home dir!"),
568 reason = "This function's behavior is unexpected and probably not what you want. \
569 Consider using a crate from crates.io instead."
572 #[stable(feature = "env", since = "1.0.0")]
573 pub fn home_dir() -> Option<PathBuf> {
577 /// Returns the path of a temporary directory.
579 /// The temporary directory may be shared among users, or between processes
580 /// with different privileges; thus, the creation of any files or directories
581 /// in the temporary directory must use a secure method to create a uniquely
582 /// named file. Creating a file or directory with a fixed or predictable name
583 /// may result in "insecure temporary file" security vulnerabilities. Consider
584 /// using a crate that securely creates temporary files or directories.
586 /// # Platform-specific behavior
588 /// On Unix, returns the value of the `TMPDIR` environment variable if it is
589 /// set, otherwise for non-Android it returns `/tmp`. If Android, since there
590 /// is no global temporary folder (it is usually allocated per-app), it returns
591 /// `/data/local/tmp`.
592 /// On Windows, the behavior is equivalent to that of [`GetTempPath2`][GetTempPath2] /
593 /// [`GetTempPath`][GetTempPath], which this function uses internally.
594 /// Note that, this [may change in the future][changes].
596 /// [changes]: io#platform-specific-behavior
597 /// [GetTempPath2]: https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettemppath2a
598 /// [GetTempPath]: https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettemppatha
604 /// let dir = env::temp_dir();
605 /// println!("Temporary directory: {}", dir.display());
609 #[stable(feature = "env", since = "1.0.0")]
610 pub fn temp_dir() -> PathBuf {
614 /// Returns the full filesystem path of the current running executable.
616 /// # Platform-specific behavior
618 /// If the executable was invoked through a symbolic link, some platforms will
619 /// return the path of the symbolic link and other platforms will return the
620 /// path of the symbolic link’s target.
622 /// If the executable is renamed while it is running, platforms may return the
623 /// path at the time it was loaded instead of the new path.
627 /// Acquiring the path of the current executable is a platform-specific operation
628 /// that can fail for a good number of reasons. Some errors can include, but not
629 /// be limited to, filesystem operations failing or general syscall failures.
633 /// The output of this function should not be used in anything that might have
634 /// security implications. For example:
638 /// println!("{:?}", std::env::current_exe());
642 /// On Linux systems, if this is compiled as `foo`:
647 /// Ok("/home/alex/foo")
650 /// And you make a hard link of the program:
656 /// When you run it, you won’t get the path of the original executable, you’ll
657 /// get the path of the hard link:
661 /// Ok("/home/alex/bar")
664 /// This sort of behavior has been known to [lead to privilege escalation] when
665 /// used incorrectly.
667 /// [lead to privilege escalation]: https://securityvulns.com/Wdocument183.html
674 /// match env::current_exe() {
675 /// Ok(exe_path) => println!("Path of this executable is: {}",
676 /// exe_path.display()),
677 /// Err(e) => println!("failed to get current exe path: {}", e),
680 #[stable(feature = "env", since = "1.0.0")]
681 pub fn current_exe() -> io::Result<PathBuf> {
682 os_imp::current_exe()
685 /// An iterator over the arguments of a process, yielding a [`String`] value for
688 /// This struct is created by [`env::args()`]. See its documentation
691 /// The first element is traditionally the path of the executable, but it can be
692 /// set to arbitrary text, and might not even exist. This means this property
693 /// should not be relied upon for security purposes.
695 /// [`env::args()`]: args
696 #[must_use = "iterators are lazy and do nothing unless consumed"]
697 #[stable(feature = "env", since = "1.0.0")]
702 /// An iterator over the arguments of a process, yielding an [`OsString`] value
703 /// for each argument.
705 /// This struct is created by [`env::args_os()`]. See its documentation
708 /// The first element is traditionally the path of the executable, but it can be
709 /// set to arbitrary text, and might not even exist. This means this property
710 /// should not be relied upon for security purposes.
712 /// [`env::args_os()`]: args_os
713 #[must_use = "iterators are lazy and do nothing unless consumed"]
714 #[stable(feature = "env", since = "1.0.0")]
716 inner: sys::args::Args,
719 /// Returns the arguments that this program was started with (normally passed
720 /// via the command line).
722 /// The first element is traditionally the path of the executable, but it can be
723 /// set to arbitrary text, and might not even exist. This means this property should
724 /// not be relied upon for security purposes.
726 /// On Unix systems the shell usually expands unquoted arguments with glob patterns
727 /// (such as `*` and `?`). On Windows this is not done, and such arguments are
730 /// On glibc Linux systems, arguments are retrieved by placing a function in `.init_array`.
731 /// glibc passes `argc`, `argv`, and `envp` to functions in `.init_array`, as a non-standard
732 /// extension. This allows `std::env::args` to work even in a `cdylib` or `staticlib`, as it
733 /// does on macOS and Windows.
737 /// The returned iterator will panic during iteration if any argument to the
738 /// process is not valid Unicode. If this is not desired,
739 /// use the [`args_os`] function instead.
746 /// // Prints each argument on a separate line
747 /// for argument in env::args() {
748 /// println!("{}", argument);
751 #[stable(feature = "env", since = "1.0.0")]
752 pub fn args() -> Args {
753 Args { inner: args_os() }
756 /// Returns the arguments that this program was started with (normally passed
757 /// via the command line).
759 /// The first element is traditionally the path of the executable, but it can be
760 /// set to arbitrary text, and might not even exist. This means this property should
761 /// not be relied upon for security purposes.
763 /// On Unix systems the shell usually expands unquoted arguments with glob patterns
764 /// (such as `*` and `?`). On Windows this is not done, and such arguments are
767 /// On glibc Linux systems, arguments are retrieved by placing a function in `.init_array`.
768 /// glibc passes `argc`, `argv`, and `envp` to functions in `.init_array`, as a non-standard
769 /// extension. This allows `std::env::args_os` to work even in a `cdylib` or `staticlib`, as it
770 /// does on macOS and Windows.
772 /// Note that the returned iterator will not check if the arguments to the
773 /// process are valid Unicode. If you want to panic on invalid UTF-8,
774 /// use the [`args`] function instead.
781 /// // Prints each argument on a separate line
782 /// for argument in env::args_os() {
783 /// println!("{:?}", argument);
786 #[stable(feature = "env", since = "1.0.0")]
787 pub fn args_os() -> ArgsOs {
788 ArgsOs { inner: sys::args::args() }
791 #[stable(feature = "env_unimpl_send_sync", since = "1.26.0")]
792 impl !Send for Args {}
794 #[stable(feature = "env_unimpl_send_sync", since = "1.26.0")]
795 impl !Sync for Args {}
797 #[stable(feature = "env", since = "1.0.0")]
798 impl Iterator for Args {
800 fn next(&mut self) -> Option<String> {
801 self.inner.next().map(|s| s.into_string().unwrap())
803 fn size_hint(&self) -> (usize, Option<usize>) {
804 self.inner.size_hint()
808 #[stable(feature = "env", since = "1.0.0")]
809 impl ExactSizeIterator for Args {
810 fn len(&self) -> usize {
813 fn is_empty(&self) -> bool {
814 self.inner.is_empty()
818 #[stable(feature = "env_iterators", since = "1.12.0")]
819 impl DoubleEndedIterator for Args {
820 fn next_back(&mut self) -> Option<String> {
821 self.inner.next_back().map(|s| s.into_string().unwrap())
825 #[stable(feature = "std_debug", since = "1.16.0")]
826 impl fmt::Debug for Args {
827 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
828 f.debug_struct("Args").field("inner", &self.inner.inner).finish()
832 #[stable(feature = "env_unimpl_send_sync", since = "1.26.0")]
833 impl !Send for ArgsOs {}
835 #[stable(feature = "env_unimpl_send_sync", since = "1.26.0")]
836 impl !Sync for ArgsOs {}
838 #[stable(feature = "env", since = "1.0.0")]
839 impl Iterator for ArgsOs {
840 type Item = OsString;
841 fn next(&mut self) -> Option<OsString> {
844 fn size_hint(&self) -> (usize, Option<usize>) {
845 self.inner.size_hint()
849 #[stable(feature = "env", since = "1.0.0")]
850 impl ExactSizeIterator for ArgsOs {
851 fn len(&self) -> usize {
854 fn is_empty(&self) -> bool {
855 self.inner.is_empty()
859 #[stable(feature = "env_iterators", since = "1.12.0")]
860 impl DoubleEndedIterator for ArgsOs {
861 fn next_back(&mut self) -> Option<OsString> {
862 self.inner.next_back()
866 #[stable(feature = "std_debug", since = "1.16.0")]
867 impl fmt::Debug for ArgsOs {
868 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
869 f.debug_struct("ArgsOs").field("inner", &self.inner).finish()
873 /// Constants associated with the current target
874 #[stable(feature = "env", since = "1.0.0")]
876 use crate::sys::env::os;
878 /// A string describing the architecture of the CPU that is currently
881 /// Some possible values:
895 #[stable(feature = "env", since = "1.0.0")]
896 pub const ARCH: &str = env!("STD_ENV_ARCH");
898 /// The family of the operating system. Example value is `unix`.
900 /// Some possible values:
904 #[stable(feature = "env", since = "1.0.0")]
905 pub const FAMILY: &str = os::FAMILY;
907 /// A string describing the specific operating system in use.
908 /// Example value is `linux`.
910 /// Some possible values:
922 #[stable(feature = "env", since = "1.0.0")]
923 pub const OS: &str = os::OS;
925 /// Specifies the filename prefix used for shared libraries on this
926 /// platform. Example value is `lib`.
928 /// Some possible values:
931 /// - `""` (an empty string)
932 #[stable(feature = "env", since = "1.0.0")]
933 pub const DLL_PREFIX: &str = os::DLL_PREFIX;
935 /// Specifies the filename suffix used for shared libraries on this
936 /// platform. Example value is `.so`.
938 /// Some possible values:
943 #[stable(feature = "env", since = "1.0.0")]
944 pub const DLL_SUFFIX: &str = os::DLL_SUFFIX;
946 /// Specifies the file extension used for shared libraries on this
947 /// platform that goes after the dot. Example value is `so`.
949 /// Some possible values:
954 #[stable(feature = "env", since = "1.0.0")]
955 pub const DLL_EXTENSION: &str = os::DLL_EXTENSION;
957 /// Specifies the filename suffix used for executable binaries on this
958 /// platform. Example value is `.exe`.
960 /// Some possible values:
965 /// - `""` (an empty string)
966 #[stable(feature = "env", since = "1.0.0")]
967 pub const EXE_SUFFIX: &str = os::EXE_SUFFIX;
969 /// Specifies the file extension, if any, used for executable binaries
970 /// on this platform. Example value is `exe`.
972 /// Some possible values:
975 /// - `""` (an empty string)
976 #[stable(feature = "env", since = "1.0.0")]
977 pub const EXE_EXTENSION: &str = os::EXE_EXTENSION;