{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/21787","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/21787/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/21787/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/21787/events","html_url":"https://github.com/rust-lang/rust/pull/21787","id":56074640,"number":21787,"title":"std: Add a new `env` module","user":{"login":"alexcrichton","id":64996,"avatar_url":"https://avatars.githubusercontent.com/u/64996?v=3","gravatar_id":"","url":"https://api.github.com/users/alexcrichton","html_url":"https://github.com/alexcrichton","followers_url":"https://api.github.com/users/alexcrichton/followers","following_url":"https://api.github.com/users/alexcrichton/following{/other_user}","gists_url":"https://api.github.com/users/alexcrichton/gists{/gist_id}","starred_url":"https://api.github.com/users/alexcrichton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexcrichton/subscriptions","organizations_url":"https://api.github.com/users/alexcrichton/orgs","repos_url":"https://api.github.com/users/alexcrichton/repos","events_url":"https://api.github.com/users/alexcrichton/events{/privacy}","received_events_url":"https://api.github.com/users/alexcrichton/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":{"login":"aturon","id":709807,"avatar_url":"https://avatars.githubusercontent.com/u/709807?v=3","gravatar_id":"","url":"https://api.github.com/users/aturon","html_url":"https://github.com/aturon","followers_url":"https://api.github.com/users/aturon/followers","following_url":"https://api.github.com/users/aturon/following{/other_user}","gists_url":"https://api.github.com/users/aturon/gists{/gist_id}","starred_url":"https://api.github.com/users/aturon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aturon/subscriptions","organizations_url":"https://api.github.com/users/aturon/orgs","repos_url":"https://api.github.com/users/aturon/repos","events_url":"https://api.github.com/users/aturon/events{/privacy}","received_events_url":"https://api.github.com/users/aturon/received_events","type":"User","site_admin":false},"milestone":null,"comments":21,"created_at":"2015-01-30T19:33:16Z","updated_at":"2015-02-06T07:45:23Z","closed_at":"2015-02-03T06:41:12Z","pull_request":{"url":"https://api.github.com/repos/rust-lang/rust/pulls/21787","html_url":"https://github.com/rust-lang/rust/pull/21787","diff_url":"https://github.com/rust-lang/rust/pull/21787.diff","patch_url":"https://github.com/rust-lang/rust/pull/21787.patch"},"body":"This is an implementation of [RFC 578][rfc] which adds a new `std::env` module\r\nto replace most of the functionality in the current `std::os` module. More\r\ndetails can be found in the RFC itself, but as a summary the following methods\r\nhave all been deprecated:\r\n\r\n[rfc]: https://github.com/rust-lang/rfcs/pull/578\r\n\r\n* `os::args_as_bytes`   => `env::args`\r\n* `os::args`            => `env::args`\r\n* `os::consts`          => `env::consts`\r\n* `os::dll_filename`    => no replacement, use `env::consts` directly\r\n* `os::page_size`       => `env::page_size`\r\n* `os::make_absolute`   => use `env::current_dir` + `join` instead\r\n* `os::getcwd`          => `env::current_dir`\r\n* `os::change_dir`      => `env::set_current_dir`\r\n* `os::homedir`         => `env::home_dir`\r\n* `os::tmpdir`          => `env::temp_dir`\r\n* `os::join_paths`      => `env::join_paths`\r\n* `os::split_paths`     => `env::split_paths`\r\n* `os::self_exe_name`   => `env::current_exe`\r\n* `os::self_exe_path`   => use `env::current_exe` + `pop`\r\n* `os::set_exit_status` => `env::set_exit_status`\r\n* `os::get_exit_status` => `env::get_exit_status`\r\n* `os::env`             => `env::vars`\r\n* `os::env_as_bytes`    => `env::vars`\r\n* `os::getenv`          => `env::var` or `env::var_string`\r\n* `os::getenv_as_bytes` => `env::var`\r\n* `os::setenv`          => `env::set_var`\r\n* `os::unsetenv`        => `env::remove_var`\r\n\r\nMany function signatures have also been tweaked for various purposes, but the\r\nmain changes were:\r\n\r\n* `Vec`-returning APIs now all return iterators instead\r\n* All APIs are now centered around `OsString` instead of `Vec<u8>` or `String`.\r\n  There is currently on convenience API, `env::var_string`, which can be used to\r\n  get the value of an environment variable as a unicode `String`.\r\n\r\nAll old APIs are `#[deprecated]` in-place and will remain for some time to allow\r\nfor migrations. The semantics of the APIs have been tweaked slightly with regard\r\nto dealing with invalid unicode (panic instead of replacement).\r\n\r\nThe new `std::env` module is all contained within the `env` feature, so crates\r\nmust add the following to access the new APIs:\r\n\r\n    #![feature(env)]\r\n\r\n[breaking-change]"},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/73198286","html_url":"https://github.com/rust-lang/rust/pull/21787#issuecomment-73198286","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/21787","id":73198286,"user":{"login":"aturon","id":709807,"avatar_url":"https://avatars.githubusercontent.com/u/709807?v=3","gravatar_id":"","url":"https://api.github.com/users/aturon","html_url":"https://github.com/aturon","followers_url":"https://api.github.com/users/aturon/followers","following_url":"https://api.github.com/users/aturon/following{/other_user}","gists_url":"https://api.github.com/users/aturon/gists{/gist_id}","starred_url":"https://api.github.com/users/aturon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aturon/subscriptions","organizations_url":"https://api.github.com/users/aturon/orgs","repos_url":"https://api.github.com/users/aturon/repos","events_url":"https://api.github.com/users/aturon/events{/privacy}","received_events_url":"https://api.github.com/users/aturon/received_events","type":"User","site_admin":false},"created_at":"2015-02-06T07:45:23Z","updated_at":"2015-02-06T07:45:23Z","body":"> This whole area seems way overdesigned. The old approach was much simpler, and the use case for all this complexity seems to be corrupted UCS-2 on Windows.\r\n\r\nThe other side of `OsString`, on Unix, is dealing with byte sequences that are not UTF-8. Since paths, arguments, environment variables, etc are just C strings (and in many systems are not required to follow any particular encoding), we need a way to represent the full space of values.\r\n\r\nNote that \"the old approach\" already had things like `env_as_bytes` to tackle the above. This has just been packaged into a more robust, cross-platform `OsString`.\r\n\r\nThat said, as I wrote above, I think we probably want to consider making the \"default\" variants work with `String` and have a separate set of more \"advanced\" forms that robust, cross-platform code would use."}}