@@ -59,7 +59,6 @@ use core::str::pattern::Pattern;
5959use core:: str:: pattern:: { Searcher , ReverseSearcher , DoubleEndedSearcher } ;
6060use rustc_unicode:: str:: { UnicodeStr , Utf16Encoder } ;
6161
62- use core:: convert:: AsRef ;
6362use vec_deque:: VecDeque ;
6463use borrow:: { Borrow , ToOwned } ;
6564use string:: String ;
@@ -83,7 +82,7 @@ pub use core::str::pattern;
8382Section: Creating a string
8483*/
8584
86- impl < S : AsRef < str > > SliceConcatExt < str > for [ S ] {
85+ impl < S : Borrow < str > > SliceConcatExt < str > for [ S ] {
8786 type Output = String ;
8887
8988 fn concat ( & self ) -> String {
@@ -92,11 +91,11 @@ impl<S: AsRef<str>> SliceConcatExt<str> for [S] {
9291 }
9392
9493 // `len` calculation may overflow but push_str will check boundaries
95- let len = self . iter ( ) . map ( |s| s. as_ref ( ) . len ( ) ) . sum ( ) ;
94+ let len = self . iter ( ) . map ( |s| s. borrow ( ) . len ( ) ) . sum ( ) ;
9695 let mut result = String :: with_capacity ( len) ;
9796
9897 for s in self {
99- result. push_str ( s. as_ref ( ) )
98+ result. push_str ( s. borrow ( ) )
10099 }
101100
102101 result
@@ -115,7 +114,7 @@ impl<S: AsRef<str>> SliceConcatExt<str> for [S] {
115114 // this is wrong without the guarantee that `self` is non-empty
116115 // `len` calculation may overflow but push_str but will check boundaries
117116 let len = sep. len ( ) * ( self . len ( ) - 1 )
118- + self . iter ( ) . map ( |s| s. as_ref ( ) . len ( ) ) . sum :: < usize > ( ) ;
117+ + self . iter ( ) . map ( |s| s. borrow ( ) . len ( ) ) . sum :: < usize > ( ) ;
119118 let mut result = String :: with_capacity ( len) ;
120119 let mut first = true ;
121120
@@ -125,7 +124,7 @@ impl<S: AsRef<str>> SliceConcatExt<str> for [S] {
125124 } else {
126125 result. push_str ( sep) ;
127126 }
128- result. push_str ( s. as_ref ( ) ) ;
127+ result. push_str ( s. borrow ( ) ) ;
129128 }
130129 result
131130 }
0 commit comments