@@ -169,7 +169,7 @@ fn with_env_lock<T>(f: || -> T) -> T {
169
169
///
170
170
/// Invalid UTF-8 bytes are replaced with \uFFFD. See `str::from_utf8_lossy()`
171
171
/// for details.
172
- pub fn env ( ) -> ~ [ ( ~str , ~str ) ] {
172
+ pub fn env ( ) -> Vec < ( ~str , ~str ) > {
173
173
env_as_bytes ( ) . move_iter ( ) . map ( |( k, v) | {
174
174
let k = str:: from_utf8_lossy ( k) . into_owned ( ) ;
175
175
let v = str:: from_utf8_lossy ( v) . into_owned ( ) ;
@@ -179,7 +179,7 @@ pub fn env() -> ~[(~str,~str)] {
179
179
180
180
/// Returns a vector of (variable, value) byte-vector pairs for all the
181
181
/// environment variables of the current process.
182
- pub fn env_as_bytes ( ) -> ~ [ ( ~[ u8 ] , ~[ u8 ] ) ] {
182
+ pub fn env_as_bytes ( ) -> Vec < ( ~[ u8 ] , ~[ u8 ] ) > {
183
183
unsafe {
184
184
#[ cfg( windows) ]
185
185
unsafe fn get_env_pairs ( ) -> Vec < ~[ u8 ] > {
@@ -224,16 +224,16 @@ pub fn env_as_bytes() -> ~[(~[u8],~[u8])] {
224
224
fn env_convert ( input : Vec < ~[ u8 ] > ) -> Vec < ( ~[ u8 ] , ~[ u8 ] ) > {
225
225
let mut pairs = Vec :: new ( ) ;
226
226
for p in input. iter ( ) {
227
- let vs : ~ [ & [ u8 ] ] = p. splitn ( 1 , |b| * b == '=' as u8 ) . collect ( ) ;
228
- let key = vs [ 0 ] . to_owned ( ) ;
229
- let val = if vs . len ( ) < 2 { box [ ] } else { vs [ 1 ] . to_owned ( ) } ;
227
+ let mut it = p. splitn ( 1 , |b| * b == '=' as u8 ) ;
228
+ let key = it . next ( ) . unwrap ( ) . to_owned ( ) ;
229
+ let val = it . next ( ) . unwrap_or ( & [ ] ) . to_owned ( ) ;
230
230
pairs. push ( ( key, val) ) ;
231
231
}
232
232
pairs
233
233
}
234
234
with_env_lock ( || {
235
235
let unparsed_environ = get_env_pairs ( ) ;
236
- env_convert ( unparsed_environ) . move_iter ( ) . collect ( )
236
+ env_convert ( unparsed_environ)
237
237
} )
238
238
}
239
239
}
@@ -416,7 +416,7 @@ pub fn dll_filename(base: &str) -> ~str {
416
416
pub fn self_exe_name ( ) -> Option < Path > {
417
417
418
418
#[ cfg( target_os = "freebsd" ) ]
419
- fn load_self ( ) -> Option < ~ [ u8 ] > {
419
+ fn load_self ( ) -> Option < Vec < u8 > > {
420
420
unsafe {
421
421
use libc:: funcs:: bsd44:: * ;
422
422
use libc:: consts:: os:: extra:: * ;
@@ -436,23 +436,23 @@ pub fn self_exe_name() -> Option<Path> {
436
436
if err != 0 { return None ; }
437
437
if sz == 0 { return None ; }
438
438
v. set_len ( sz as uint - 1 ) ; // chop off trailing NUL
439
- Some ( v. move_iter ( ) . collect ( ) )
439
+ Some ( v)
440
440
}
441
441
}
442
442
443
443
#[ cfg( target_os = "linux" ) ]
444
444
#[ cfg( target_os = "android" ) ]
445
- fn load_self ( ) -> Option < ~ [ u8 ] > {
445
+ fn load_self ( ) -> Option < Vec < u8 > > {
446
446
use std:: io;
447
447
448
448
match io:: fs:: readlink ( & Path :: new ( "/proc/self/exe" ) ) {
449
- Ok ( path) => Some ( path. as_vec ( ) . to_owned ( ) ) ,
449
+ Ok ( path) => Some ( path. into_vec ( ) ) ,
450
450
Err ( ..) => None
451
451
}
452
452
}
453
453
454
454
#[ cfg( target_os = "macos" ) ]
455
- fn load_self ( ) -> Option < ~ [ u8 ] > {
455
+ fn load_self ( ) -> Option < Vec < u8 > > {
456
456
unsafe {
457
457
use libc:: funcs:: extra:: _NSGetExecutablePath;
458
458
let mut sz: u32 = 0 ;
@@ -462,19 +462,19 @@ pub fn self_exe_name() -> Option<Path> {
462
462
let err = _NSGetExecutablePath ( v. as_mut_ptr ( ) as * mut i8 , & mut sz) ;
463
463
if err != 0 { return None ; }
464
464
v. set_len ( sz as uint - 1 ) ; // chop off trailing NUL
465
- Some ( v. move_iter ( ) . collect ( ) )
465
+ Some ( v)
466
466
}
467
467
}
468
468
469
469
#[ cfg( windows) ]
470
- fn load_self ( ) -> Option < ~ [ u8 ] > {
470
+ fn load_self ( ) -> Option < Vec < u8 > > {
471
471
use str:: OwnedStr ;
472
472
473
473
unsafe {
474
474
use os:: win32:: fill_utf16_buf_and_decode;
475
475
fill_utf16_buf_and_decode ( |buf, sz| {
476
476
libc:: GetModuleFileNameW ( 0 u as libc:: DWORD , buf, sz)
477
- } ) . map ( |s| s. into_bytes ( ) )
477
+ } ) . map ( |s| s. into_strbuf ( ) . into_bytes ( ) )
478
478
}
479
479
}
480
480
@@ -789,12 +789,12 @@ pub fn get_exit_status() -> int {
789
789
}
790
790
791
791
#[ cfg( target_os = "macos" ) ]
792
- unsafe fn load_argc_and_argv ( argc : int , argv : * * c_char ) -> ~ [ ~ [ u8 ] ] {
792
+ unsafe fn load_argc_and_argv ( argc : int , argv : * * c_char ) -> Vec < ~ [ u8 ] > {
793
793
use c_str:: CString ;
794
794
795
795
Vec :: from_fn ( argc as uint , |i| {
796
796
CString :: new ( * argv. offset ( i as int ) , false ) . as_bytes_no_nul ( ) . to_owned ( )
797
- } ) . move_iter ( ) . collect ( )
797
+ } )
798
798
}
799
799
800
800
/**
@@ -803,7 +803,7 @@ unsafe fn load_argc_and_argv(argc: int, argv: **c_char) -> ~[~[u8]] {
803
803
* Returns a list of the command line arguments.
804
804
*/
805
805
#[ cfg( target_os = "macos" ) ]
806
- fn real_args_as_bytes ( ) -> ~ [ ~ [ u8 ] ] {
806
+ fn real_args_as_bytes ( ) -> Vec < ~ [ u8 ] > {
807
807
unsafe {
808
808
let ( argc, argv) = ( * _NSGetArgc ( ) as int ,
809
809
* _NSGetArgv ( ) as * * c_char ) ;
@@ -814,7 +814,7 @@ fn real_args_as_bytes() -> ~[~[u8]] {
814
814
#[ cfg( target_os = "linux" ) ]
815
815
#[ cfg( target_os = "android" ) ]
816
816
#[ cfg( target_os = "freebsd" ) ]
817
- fn real_args_as_bytes ( ) -> ~ [ ~ [ u8 ] ] {
817
+ fn real_args_as_bytes ( ) -> Vec < ~ [ u8 ] > {
818
818
use rt;
819
819
820
820
match rt:: args:: clone ( ) {
@@ -824,12 +824,12 @@ fn real_args_as_bytes() -> ~[~[u8]] {
824
824
}
825
825
826
826
#[ cfg( not( windows) ) ]
827
- fn real_args ( ) -> ~ [ ~ str ] {
827
+ fn real_args ( ) -> Vec < ~ str > {
828
828
real_args_as_bytes ( ) . move_iter ( ) . map ( |v| str:: from_utf8_lossy ( v) . into_owned ( ) ) . collect ( )
829
829
}
830
830
831
831
#[ cfg( windows) ]
832
- fn real_args ( ) -> ~ [ ~ str ] {
832
+ fn real_args ( ) -> Vec < ~ str > {
833
833
use slice;
834
834
use option:: Expect ;
835
835
@@ -855,11 +855,11 @@ fn real_args() -> ~[~str] {
855
855
LocalFree ( szArgList as * c_void ) ;
856
856
}
857
857
858
- return args. move_iter ( ) . collect ( ) ;
858
+ return args
859
859
}
860
860
861
861
#[ cfg( windows) ]
862
- fn real_args_as_bytes ( ) -> ~ [ ~ [ u8 ] ] {
862
+ fn real_args_as_bytes ( ) -> Vec < ~ [ u8 ] > {
863
863
real_args ( ) . move_iter ( ) . map ( |s| s. into_bytes ( ) ) . collect ( )
864
864
}
865
865
@@ -883,13 +883,13 @@ extern "system" {
883
883
///
884
884
/// The arguments are interpreted as utf-8, with invalid bytes replaced with \uFFFD.
885
885
/// See `str::from_utf8_lossy` for details.
886
- pub fn args ( ) -> ~ [ ~ str ] {
886
+ pub fn args ( ) -> Vec < ~ str > {
887
887
real_args ( )
888
888
}
889
889
890
890
/// Returns the arguments which this program was started with (normally passed
891
891
/// via the command line) as byte vectors.
892
- pub fn args_as_bytes ( ) -> ~ [ ~ [ u8 ] ] {
892
+ pub fn args_as_bytes ( ) -> Vec < ~ [ u8 ] > {
893
893
real_args_as_bytes ( )
894
894
}
895
895
0 commit comments