{"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":20,"created_at":"2015-01-30T19:33:16Z","updated_at":"2015-02-06T07:38:02Z","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/73197467","html_url":"https://github.com/rust-lang/rust/pull/21787#issuecomment-73197467","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/21787","id":73197467,"user":{"login":"John-Nagle","id":942608,"avatar_url":"https://avatars.githubusercontent.com/u/942608?v=3","gravatar_id":"","url":"https://api.github.com/users/John-Nagle","html_url":"https://github.com/John-Nagle","followers_url":"https://api.github.com/users/John-Nagle/followers","following_url":"https://api.github.com/users/John-Nagle/following{/other_user}","gists_url":"https://api.github.com/users/John-Nagle/gists{/gist_id}","starred_url":"https://api.github.com/users/John-Nagle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/John-Nagle/subscriptions","organizations_url":"https://api.github.com/users/John-Nagle/orgs","repos_url":"https://api.github.com/users/John-Nagle/repos","events_url":"https://api.github.com/users/John-Nagle/events{/privacy}","received_events_url":"https://api.github.com/users/John-Nagle/received_events","type":"User","site_admin":false},"created_at":"2015-02-06T07:38:02Z","updated_at":"2015-02-06T07:38:02Z","body":"*Are you implying any system which uses non utf-8 locale is broken?*\r\nNo, that's handled. OsString is an opaque type. See\r\nhttps://github.com/rust-lang/rfcs/blob/master/text/0517-io-os-reform.md#the-design-os_str\r\nespecially where it says \"but CRUCIALLY NOT as_bytes\". If OsString values are locale sensitive, the OS support package for that platform must deal with it invisibly to the Rust program.\r\n\r\nThis 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. Anything Windows can represent as UCS-2, even with surrogate pairs, can be represented as a UTF-8 Rust string. Some conversions in the other direction won't work, and they should raise exceptions. Yes, this may mean that you can't put emoji into a Windows file name. "}}