diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-06-02 14:51:58 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-06-09 17:46:27 -0700 |
| commit | d42cc130f9eaaa4b35944854c3ba34ae98d6361e (patch) | |
| tree | 02caa183a0848d2533948c9bb8a9fbf7f6b45677 /src/libstd/unstable | |
| parent | 0ea7aa30cc864d00fc30b9ba610f2daefab4e850 (diff) | |
std: Remove the as_utf16_p functions
These functions are all much better expressed via RAII using the to_utf16() method on strings. This refactoring also takes this opportunity to properly handle when filenames aren't valid unicode when passed through to the windows I/O layer by properly returning I/O errors. All previous users of the `as_utf16_p` or `as_utf16_mut_p` functions will need to convert their code to using `foo.to_utf16().append_one(0)` to get a null-terminated utf16 string. [breaking-change]
Diffstat (limited to 'src/libstd/unstable')
| -rw-r--r-- | src/libstd/unstable/dynamic_lib.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/libstd/unstable/dynamic_lib.rs b/src/libstd/unstable/dynamic_lib.rs index c05cdc85cc5..6980c5cc0c2 100644 --- a/src/libstd/unstable/dynamic_lib.rs +++ b/src/libstd/unstable/dynamic_lib.rs @@ -272,21 +272,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 { |
