Skip to content

Commit 55fe6d8

Browse files
committed
Add documentation to std::env::args[_os]
1 parent e282b22 commit 55fe6d8

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/libstd/env.rs

+10
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,11 @@ pub struct ArgsOs { inner: sys::args::Args }
702702
/// (such as `*` and `?`). On Windows this is not done, and such arguments are
703703
/// passed as-is.
704704
///
705+
/// On glibc Linux, arguments are retrieved by placing a function in .init_array.
706+
/// glibc passes argc, argv, and envp to functions in .init_array, as a non-standard extension.
707+
/// This allows `std::env::args` to work even in a `cdylib` or `staticlib`, as it does on macOS
708+
/// and Windows.
709+
///
705710
/// # Panics
706711
///
707712
/// The returned iterator will panic during iteration if any argument to the
@@ -732,6 +737,11 @@ pub fn args() -> Args {
732737
/// set to arbitrary text, and it may not even exist, so this property should
733738
/// not be relied upon for security purposes.
734739
///
740+
/// On glibc Linux, arguments are retrieved by placing a function in .init_array.
741+
/// glibc passes argc, argv, and envp to functions in .init_array, as a non-standard extension.
742+
/// This allows `std::env::args` to work even in a `cdylib` or `staticlib`, as it does on macOS
743+
/// and Windows.
744+
///
735745
/// # Examples
736746
///
737747
/// ```

0 commit comments

Comments
 (0)