@@ -1002,31 +1002,33 @@ pub fn retain<T>(v: &mut ~[T], f: &fn(t: &T) -> bool) {
10021002}
10031003
10041004/// Flattens a vector of vectors of T into a single vector of T.
1005- pub fn concat < T : Copy > ( v : & [ ~[ T ] ] ) -> ~[ T ] { v. concat ( ) }
1005+ pub fn concat < T : Copy > ( v : & [ ~[ T ] ] ) -> ~[ T ] { v. concat_vec ( ) }
10061006
10071007/// Concatenate a vector of vectors, placing a given separator between each
1008- pub fn connect < T : Copy > ( v : & [ ~[ T ] ] , sep : & T ) -> ~[ T ] { v. connect ( sep) }
1008+ pub fn connect < T : Copy > ( v : & [ ~[ T ] ] , sep : & T ) -> ~[ T ] { v. connect_vec ( sep) }
10091009
10101010/// Flattens a vector of vectors of T into a single vector of T.
1011- pub fn concat_slices < T : Copy > ( v : & [ & [ T ] ] ) -> ~[ T ] { v. concat ( ) }
1011+ pub fn concat_slices < T : Copy > ( v : & [ & [ T ] ] ) -> ~[ T ] { v. concat_vec ( ) }
10121012
10131013/// Concatenate a vector of vectors, placing a given separator between each
1014- pub fn connect_slices < T : Copy > ( v : & [ & [ T ] ] , sep : & T ) -> ~[ T ] { v. connect ( sep) }
1014+ pub fn connect_slices < T : Copy > ( v : & [ & [ T ] ] , sep : & T ) -> ~[ T ] { v. connect_vec ( sep) }
10151015
10161016#[ allow( missing_doc) ]
10171017pub trait VectorVector < T > {
1018- pub fn concat ( & self ) -> ~[ T ] ;
1019- pub fn connect ( & self , sep : & T ) -> ~[ T ] ;
1018+ // FIXME #5898: calling these .concat and .connect conflicts with
1019+ // StrVector::con{cat,nect}, since they have generic contents.
1020+ pub fn concat_vec ( & self ) -> ~[ T ] ;
1021+ pub fn connect_vec ( & self , sep : & T ) -> ~[ T ] ;
10201022}
10211023
10221024impl < ' self , T : Copy > VectorVector < T > for & ' self [ ~[ T ] ] {
10231025 /// Flattens a vector of slices of T into a single vector of T.
1024- pub fn concat ( & self ) -> ~[ T ] {
1026+ pub fn concat_vec ( & self ) -> ~[ T ] {
10251027 self . flat_map ( |& inner| inner)
10261028 }
10271029
10281030 /// Concatenate a vector of vectors, placing a given separator between each.
1029- pub fn connect ( & self , sep : & T ) -> ~[ T ] {
1031+ pub fn connect_vec ( & self , sep : & T ) -> ~[ T ] {
10301032 let mut r = ~[ ] ;
10311033 let mut first = true ;
10321034 for self . each |& inner| {
@@ -1039,12 +1041,12 @@ impl<'self, T:Copy> VectorVector<T> for &'self [~[T]] {
10391041
10401042impl < ' self , T : Copy > VectorVector < T > for & ' self [ & ' self [ T ] ] {
10411043 /// Flattens a vector of slices of T into a single vector of T.
1042- pub fn concat ( & self ) -> ~[ T ] {
1044+ pub fn concat_vec ( & self ) -> ~[ T ] {
10431045 self . flat_map ( |& inner| inner. to_owned ( ) )
10441046 }
10451047
10461048 /// Concatenate a vector of slices, placing a given separator between each.
1047- pub fn connect ( & self , sep : & T ) -> ~[ T ] {
1049+ pub fn connect_vec ( & self , sep : & T ) -> ~[ T ] {
10481050 let mut r = ~[ ] ;
10491051 let mut first = true ;
10501052 for self . each |& inner| {
@@ -3639,25 +3641,25 @@ mod tests {
36393641 #[ test]
36403642 fn test_concat ( ) {
36413643 assert_eq ! ( concat( [ ~[ 1 ] , ~[ 2 , 3 ] ] ) , ~[ 1 , 2 , 3 ] ) ;
3642- assert_eq ! ( [ ~[ 1 ] , ~[ 2 , 3 ] ] . concat ( ) , ~[ 1 , 2 , 3 ] ) ;
3644+ assert_eq ! ( [ ~[ 1 ] , ~[ 2 , 3 ] ] . concat_vec ( ) , ~[ 1 , 2 , 3 ] ) ;
36433645
36443646 assert_eq ! ( concat_slices( [ & [ 1 ] , & [ 2 , 3 ] ] ) , ~[ 1 , 2 , 3 ] ) ;
3645- assert_eq ! ( [ & [ 1 ] , & [ 2 , 3 ] ] . concat ( ) , ~[ 1 , 2 , 3 ] ) ;
3647+ assert_eq ! ( [ & [ 1 ] , & [ 2 , 3 ] ] . concat_vec ( ) , ~[ 1 , 2 , 3 ] ) ;
36463648 }
36473649
36483650 #[ test]
36493651 fn test_connect ( ) {
36503652 assert_eq ! ( connect( [ ] , & 0 ) , ~[ ] ) ;
36513653 assert_eq ! ( connect( [ ~[ 1 ] , ~[ 2 , 3 ] ] , & 0 ) , ~[ 1 , 0 , 2 , 3 ] ) ;
36523654 assert_eq ! ( connect( [ ~[ 1 ] , ~[ 2 ] , ~[ 3 ] ] , & 0 ) , ~[ 1 , 0 , 2 , 0 , 3 ] ) ;
3653- assert_eq ! ( [ ~[ 1 ] , ~[ 2 , 3 ] ] . connect ( & 0 ) , ~[ 1 , 0 , 2 , 3 ] ) ;
3654- assert_eq ! ( [ ~[ 1 ] , ~[ 2 ] , ~[ 3 ] ] . connect ( & 0 ) , ~[ 1 , 0 , 2 , 0 , 3 ] ) ;
3655+ assert_eq ! ( [ ~[ 1 ] , ~[ 2 , 3 ] ] . connect_vec ( & 0 ) , ~[ 1 , 0 , 2 , 3 ] ) ;
3656+ assert_eq ! ( [ ~[ 1 ] , ~[ 2 ] , ~[ 3 ] ] . connect_vec ( & 0 ) , ~[ 1 , 0 , 2 , 0 , 3 ] ) ;
36553657
36563658 assert_eq ! ( connect_slices( [ ] , & 0 ) , ~[ ] ) ;
36573659 assert_eq ! ( connect_slices( [ & [ 1 ] , & [ 2 , 3 ] ] , & 0 ) , ~[ 1 , 0 , 2 , 3 ] ) ;
36583660 assert_eq ! ( connect_slices( [ & [ 1 ] , & [ 2 ] , & [ 3 ] ] , & 0 ) , ~[ 1 , 0 , 2 , 0 , 3 ] ) ;
3659- assert_eq ! ( [ & [ 1 ] , & [ 2 , 3 ] ] . connect ( & 0 ) , ~[ 1 , 0 , 2 , 3 ] ) ;
3660- assert_eq ! ( [ & [ 1 ] , & [ 2 ] , & [ 3 ] ] . connect ( & 0 ) , ~[ 1 , 0 , 2 , 0 , 3 ] ) ;
3661+ assert_eq ! ( [ & [ 1 ] , & [ 2 , 3 ] ] . connect_vec ( & 0 ) , ~[ 1 , 0 , 2 , 3 ] ) ;
3662+ assert_eq ! ( [ & [ 1 ] , & [ 2 ] , & [ 3 ] ] . connect_vec ( & 0 ) , ~[ 1 , 0 , 2 , 0 , 3 ] ) ;
36613663 }
36623664
36633665 #[ test]
0 commit comments