@@ -59,7 +59,6 @@ use core::str::pattern::Pattern;
59
59
use core:: str:: pattern:: { Searcher , ReverseSearcher , DoubleEndedSearcher } ;
60
60
use rustc_unicode:: str:: { UnicodeStr , Utf16Encoder } ;
61
61
62
- use core:: convert:: AsRef ;
63
62
use vec_deque:: VecDeque ;
64
63
use borrow:: { Borrow , ToOwned } ;
65
64
use string:: String ;
@@ -83,7 +82,7 @@ pub use core::str::pattern;
83
82
Section: Creating a string
84
83
*/
85
84
86
- impl < S : AsRef < str > > SliceConcatExt < str > for [ S ] {
85
+ impl < S : Borrow < str > > SliceConcatExt < str > for [ S ] {
87
86
type Output = String ;
88
87
89
88
fn concat ( & self ) -> String {
@@ -92,11 +91,11 @@ impl<S: AsRef<str>> SliceConcatExt<str> for [S] {
92
91
}
93
92
94
93
// `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 ( ) ;
96
95
let mut result = String :: with_capacity ( len) ;
97
96
98
97
for s in self {
99
- result. push_str ( s. as_ref ( ) )
98
+ result. push_str ( s. borrow ( ) )
100
99
}
101
100
102
101
result
@@ -115,7 +114,7 @@ impl<S: AsRef<str>> SliceConcatExt<str> for [S] {
115
114
// this is wrong without the guarantee that `self` is non-empty
116
115
// `len` calculation may overflow but push_str but will check boundaries
117
116
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 > ( ) ;
119
118
let mut result = String :: with_capacity ( len) ;
120
119
let mut first = true ;
121
120
@@ -125,7 +124,7 @@ impl<S: AsRef<str>> SliceConcatExt<str> for [S] {
125
124
} else {
126
125
result. push_str ( sep) ;
127
126
}
128
- result. push_str ( s. as_ref ( ) ) ;
127
+ result. push_str ( s. borrow ( ) ) ;
129
128
}
130
129
result
131
130
}
0 commit comments