Skip to content

Commit 17e0089

Browse files
committed
std: remove use of cast module from os.
1 parent 3629f70 commit 17e0089

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

src/libstd/os.rs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#[allow(missing_doc)];
3030

3131
use c_str::ToCStr;
32-
use cast;
3332
use clone::Clone;
3433
use container::Container;
3534
use io;
@@ -246,10 +245,10 @@ pub fn getenv(n: &str) -> Option<~str> {
246245
let s = do n.to_c_str().with_ref |buf| {
247246
libc::getenv(buf)
248247
};
249-
if ptr::null::<u8>() == cast::transmute(s) {
248+
if s.is_null() {
250249
None
251250
} else {
252-
Some(str::raw::from_buf(cast::transmute(s)))
251+
Some(str::raw::from_c_str(s))
253252
}
254253
}
255254
}
@@ -643,8 +642,7 @@ pub fn make_dir(p: &Path, mode: c_int) -> bool {
643642
use os::win32::as_utf16_p;
644643
// FIXME: turn mode into something useful? #2623
645644
do as_utf16_p(p.to_str()) |buf| {
646-
libc::CreateDirectoryW(buf, cast::transmute(0))
647-
!= (0 as libc::BOOL)
645+
libc::CreateDirectoryW(buf, ptr::null()) != (0 as libc::BOOL)
648646
}
649647
}
650648
}
@@ -748,10 +746,7 @@ pub fn list_dir(p: &Path) -> ~[~str] {
748746
do as_utf16_p(star(p).to_str()) |path_ptr| {
749747
let mut strings = ~[];
750748
let wfd_ptr = malloc_raw(rust_list_dir_wfd_size() as uint);
751-
let find_handle =
752-
FindFirstFileW(
753-
path_ptr,
754-
::cast::transmute(wfd_ptr));
749+
let find_handle = FindFirstFileW(path_ptr, wfd_ptr as HANDLE);
755750
if find_handle as libc::c_int != INVALID_HANDLE_VALUE {
756751
let mut more_files = 1 as libc::c_int;
757752
while more_files != 0 {
@@ -765,9 +760,7 @@ pub fn list_dir(p: &Path) -> ~[~str] {
765760
let fp_str = str::from_utf16(fp_vec);
766761
strings.push(fp_str);
767762
}
768-
more_files = FindNextFileW(
769-
find_handle,
770-
::cast::transmute(wfd_ptr));
763+
more_files = FindNextFileW(find_handle, wfd_ptr as HANDLE);
771764
}
772765
FindClose(find_handle);
773766
free(wfd_ptr)
@@ -1195,7 +1188,7 @@ pub fn real_args() -> ~[~str] {
11951188
}
11961189

11971190
unsafe {
1198-
LocalFree(cast::transmute(szArgList));
1191+
LocalFree(szArgList as *c_void);
11991192
}
12001193

12011194
return args;

0 commit comments

Comments
 (0)