Skip to content

Document std::env::const values #25668

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 27, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions src/libstd/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -598,40 +598,94 @@ pub fn page_size() -> usize {
pub mod consts {
/// A string describing the architecture of the CPU that this is currently
/// in use.
///
/// Some possible values:
///
/// - x86
/// - x86_64
/// - arm
/// - aarch64
/// - mips
/// - mipsel
/// - powerpc
#[stable(feature = "env", since = "1.0.0")]
pub const ARCH: &'static str = super::arch::ARCH;

/// The family of the operating system. In this case, `unix`.
///
/// Some possible values:
///
/// - unix
/// - windows
#[stable(feature = "env", since = "1.0.0")]
pub const FAMILY: &'static str = super::os::FAMILY;

/// A string describing the specific operating system in use: in this
/// case, `linux`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a leftover? I don't think this documentation is Linux-specific.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation is currently built on Linux, and so all of these examples have something like this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this file generated by some script? Otherwise this should probably be changed.

///
/// Some possible values:
///
/// - linux
/// - macos
/// - ios
/// - freebsd
/// - dragonfly
/// - bitrig
/// - openbsd
/// - android
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing something for windows?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoops, that was the last line of my git grep, accidentally deleted it

/// - windows
#[stable(feature = "env", since = "1.0.0")]
pub const OS: &'static str = super::os::OS;

/// Specifies the filename prefix used for shared libraries on this
/// platform: in this case, `lib`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be nice to identify which values are used on which platforms.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that something we want to directly guarantee? Not sure what benefit that would bring, maybe I'm wrong.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have to guarantee anything, but if we're going to enumerate the values that exist it seems like we might as well say "empty string on Windows, 'lib' on everything else".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess my implicit assumption is that if it's documented, it's guaranteed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're willing to document that lib and "" are the possible values here it does not seem much of a stretch to document when each is used. I can't imagine we're going to end up building foo.dll instead of libfoo.so on Linux any time soon :)

///
/// Some possible values:
///
/// - lib
/// - `""` (an empty string)
#[stable(feature = "env", since = "1.0.0")]
pub const DLL_PREFIX: &'static str = super::os::DLL_PREFIX;

/// Specifies the filename suffix used for shared libraries on this
/// platform: in this case, `.so`.
///
/// Some possible values:
///
/// - .so
/// - .dylib
/// - .dll
#[stable(feature = "env", since = "1.0.0")]
pub const DLL_SUFFIX: &'static str = super::os::DLL_SUFFIX;

/// Specifies the file extension used for shared libraries on this
/// platform that goes after the dot: in this case, `so`.
///
/// Some possible values:
///
/// - .so
/// - .dylib
/// - .dll
#[stable(feature = "env", since = "1.0.0")]
pub const DLL_EXTENSION: &'static str = super::os::DLL_EXTENSION;

/// Specifies the filename suffix used for executable binaries on this
/// platform: in this case, the empty string.
///
/// Some possible values:
///
/// - exe
/// - `""` (an empty string)
#[stable(feature = "env", since = "1.0.0")]
pub const EXE_SUFFIX: &'static str = super::os::EXE_SUFFIX;

/// Specifies the file extension, if any, used for executable binaries
/// on this platform: in this case, the empty string.
///
/// Some possible values:
///
/// - exe
/// - `""` (an empty string)
#[stable(feature = "env", since = "1.0.0")]
pub const EXE_EXTENSION: &'static str = super::os::EXE_EXTENSION;

Expand Down