diff options
| author | bors <bors@rust-lang.org> | 2014-06-09 21:57:09 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-06-09 21:57:09 -0700 |
| commit | 5bc2d03955618664377e98352d784a7f145db24a (patch) | |
| tree | ab76e5ea82592a803694bf232e983734482ba088 /src/libstd | |
| parent | 5bf5cc605fd2732fa35b284a4401bfaa899dcae2 (diff) | |
| parent | 5ede96c2fd62a63e75cb5faf073933d914f3eeaf (diff) | |
| download | rust-5bc2d03955618664377e98352d784a7f145db24a.tar.gz rust-5bc2d03955618664377e98352d784a7f145db24a.zip | |
auto merge of #14783 : alexcrichton/rust/rollup, r=alexcrichton
Closes #14611 (std: Remove the as_utf16_p functions) Closes #14694 (Num cleanup) Closes #14760 (Add --color to test binary options) Closes #14763 (std: Move dynamic_lib from std::unstable to std) Closes #14766 (Add test for issue #13446) Closes #14769 (collections: Add missing Default impls) Closes #14773 (General nits) Closes #14776 (rustdoc: Correctly classify enums/typedefs)
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/dynamic_lib.rs (renamed from src/libstd/unstable/dynamic_lib.rs) | 13 | ||||
| -rw-r--r-- | src/libstd/io/mod.rs | 7 | ||||
| -rw-r--r-- | src/libstd/lib.rs | 13 | ||||
| -rw-r--r-- | src/libstd/os.rs | 46 | ||||
| -rw-r--r-- | src/libstd/rt/backtrace.rs | 2 | ||||
| -rw-r--r-- | src/libstd/unstable/mod.rs | 13 |
6 files changed, 39 insertions, 55 deletions
diff --git a/src/libstd/unstable/dynamic_lib.rs b/src/libstd/dynamic_lib.rs index c05cdc85cc5..fa6efc8a4b1 100644 --- a/src/libstd/unstable/dynamic_lib.rs +++ b/src/libstd/dynamic_lib.rs @@ -16,6 +16,9 @@ A simple wrapper over the platform's dynamic library facilities */ +#![experimental] +#![allow(missing_doc)] + use clone::Clone; use c_str::ToCStr; use iter::Iterator; @@ -272,21 +275,21 @@ pub mod dl { #[cfg(target_os = "win32")] pub mod dl { + use c_str::ToCStr; use libc; use os; use ptr; use result::{Ok, Err, Result}; - use string::String; + use str::StrAllocating; use str; - use c_str::ToCStr; + use string::String; pub unsafe fn open_external<T: ToCStr>(filename: T) -> *u8 { // Windows expects Unicode data let filename_cstr = filename.to_c_str(); let filename_str = str::from_utf8(filename_cstr.as_bytes_no_nul()).unwrap(); - os::win32::as_utf16_p(filename_str, |raw_name| { - LoadLibraryW(raw_name as *libc::c_void) as *u8 - }) + let filename_str = filename_str.to_utf16().append_one(0); + LoadLibraryW(filename_str.as_ptr() as *libc::c_void) as *u8 } pub unsafe fn open_internal() -> *u8 { diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index 6f3eec01e8e..a1e0fa88978 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -81,13 +81,18 @@ Some examples of obvious things you might want to do * Make a simple TCP client connection and request - ```rust,should_fail + ```rust # #![allow(unused_must_use)] use std::io::net::tcp::TcpStream; + # // connection doesn't fail if a server is running on 8080 + # // locally, we still want to be type checking this code, so lets + # // just stop it running (#11576) + # if false { let mut socket = TcpStream::connect("127.0.0.1", 8080).unwrap(); socket.write(bytes!("GET / HTTP/1.0\n\n")); let response = socket.read_to_end(); + # } ``` * Make a simple TCP server diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 85813c02d55..e147997334c 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -241,15 +241,12 @@ pub mod sync; /* Runtime and platform support */ pub mod c_vec; +pub mod dynamic_lib; pub mod os; pub mod io; pub mod path; pub mod fmt; -// Private APIs -#[unstable] -pub mod unstable; - // FIXME #7809: This shouldn't be pub, and it should be reexported under 'unstable' // but name resolution doesn't work without it being pub. #[unstable] @@ -279,3 +276,11 @@ mod std { // The test runner requires std::slice::Vector, so re-export std::slice just for it. #[cfg(test)] pub use slice; } + +#[deprecated] +#[allow(missing_doc)] +#[doc(hiden)] +pub mod unstable { + #[deprecated = "use std::dynamic_lib"] + pub use dynamic_lib; +} diff --git a/src/libstd/os.rs b/src/libstd/os.rs index 90df18106f0..fa882e7d016 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -133,7 +133,7 @@ pub mod win32 { use os::TMPBUF_SZ; use slice::{MutableVector, ImmutableVector}; use string::String; - use str::{StrSlice, StrAllocating}; + use str::StrSlice; use str; use vec::Vec; @@ -171,17 +171,6 @@ pub mod win32 { return res; } } - - pub fn as_utf16_p<T>(s: &str, f: |*u16| -> T) -> T { - as_mut_utf16_p(s, |t| { f(t as *u16) }) - } - - pub fn as_mut_utf16_p<T>(s: &str, f: |*mut u16| -> T) -> T { - let mut t = s.to_utf16(); - // Null terminate before passing on. - t.push(0u16); - f(t.as_mut_ptr()) - } } /* @@ -356,11 +345,10 @@ pub fn getenv_as_bytes(n: &str) -> Option<Vec<u8>> { pub fn getenv(n: &str) -> Option<String> { unsafe { with_env_lock(|| { - use os::win32::{as_utf16_p, fill_utf16_buf_and_decode}; - as_utf16_p(n, |u| { - fill_utf16_buf_and_decode(|buf, sz| { - libc::GetEnvironmentVariableW(u, buf, sz) - }) + use os::win32::{fill_utf16_buf_and_decode}; + let n = n.to_utf16().append_one(0); + fill_utf16_buf_and_decode(|buf, sz| { + libc::GetEnvironmentVariableW(n.as_ptr(), buf, sz) }) }) } @@ -398,14 +386,11 @@ pub fn setenv(n: &str, v: &str) { /// Sets the environment variable `n` to the value `v` for the currently running /// process pub fn setenv(n: &str, v: &str) { + let n = n.to_utf16().append_one(0); + let v = v.to_utf16().append_one(0); unsafe { with_env_lock(|| { - use os::win32::as_utf16_p; - as_utf16_p(n, |nbuf| { - as_utf16_p(v, |vbuf| { - libc::SetEnvironmentVariableW(nbuf, vbuf); - }) - }) + libc::SetEnvironmentVariableW(n.as_ptr(), v.as_ptr()); }) } } @@ -428,12 +413,10 @@ pub fn unsetenv(n: &str) { } #[cfg(windows)] fn _unsetenv(n: &str) { + let n = n.to_utf16().append_one(0); unsafe { with_env_lock(|| { - use os::win32::as_utf16_p; - as_utf16_p(n, |nbuf| { - libc::SetEnvironmentVariableW(nbuf, ptr::null()); - }) + libc::SetEnvironmentVariableW(n.as_ptr(), ptr::null()); }) } } @@ -732,11 +715,12 @@ pub fn change_dir(p: &Path) -> bool { #[cfg(windows)] fn chdir(p: &Path) -> bool { + let p = match p.as_str() { + Some(s) => s.to_utf16().append_one(0), + None => return false, + }; unsafe { - use os::win32::as_utf16_p; - return as_utf16_p(p.as_str().unwrap(), |buf| { - libc::SetCurrentDirectoryW(buf) != (0 as libc::BOOL) - }); + libc::SetCurrentDirectoryW(p.as_ptr()) != (0 as libc::BOOL) } } diff --git a/src/libstd/rt/backtrace.rs b/src/libstd/rt/backtrace.rs index 83fc95267af..423f372f018 100644 --- a/src/libstd/rt/backtrace.rs +++ b/src/libstd/rt/backtrace.rs @@ -614,7 +614,7 @@ mod imp { use rt::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT}; use slice::ImmutableVector; use str::StrSlice; - use unstable::dynamic_lib::DynamicLibrary; + use dynamic_lib::DynamicLibrary; #[allow(non_snake_case_functions)] extern "system" { diff --git a/src/libstd/unstable/mod.rs b/src/libstd/unstable/mod.rs deleted file mode 100644 index 985ef2e142c..00000000000 --- a/src/libstd/unstable/mod.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![doc(hidden)] - -pub mod dynamic_lib; |
