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