File tree 1 file changed +12
-4
lines changed
1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -323,14 +323,22 @@ impl<T> ByteSubstring<T> where T: AsRef<[u8]> {
323
323
/// A convenience type that can be used in a constant or static.
324
324
pub type ByteSubstringConst = ByteSubstring < & ' static [ u8 ] > ;
325
325
326
- /// Searches a string for the first occurence of the substring.
327
- pub struct Substring < ' a > ( ByteSubstring < & ' a [ u8 ] > ) ;
326
+ /// Searches a string for the first occurrence of the substring.
327
+ pub struct Substring < T > ( ByteSubstring < T > ) ;
328
328
329
- impl < ' a > Substring < ' a > {
329
+ impl < ' a > Substring < & ' a [ u8 ] > {
330
330
pub /* const */ fn new ( needle : & ' a str ) -> Self {
331
331
Substring ( ByteSubstring :: new ( needle. as_bytes ( ) ) )
332
332
}
333
+ }
334
+
335
+ impl Substring < Vec < u8 > > {
336
+ pub fn new_owned ( needle : String ) -> Self {
337
+ Substring ( ByteSubstring :: new ( needle. into_bytes ( ) ) )
338
+ }
339
+ }
333
340
341
+ impl < T > Substring < T > where T : AsRef < [ u8 ] > {
334
342
#[ cfg( feature = "pattern" ) ]
335
343
fn needle_len ( & self ) -> usize {
336
344
self . 0 . needle_len ( )
@@ -344,7 +352,7 @@ impl<'a> Substring<'a> {
344
352
}
345
353
346
354
/// A convenience type that can be used in a constant or static.
347
- pub type SubstringConst = Substring < ' static > ;
355
+ pub type SubstringConst = Substring < & ' static str > ;
348
356
349
357
#[ cfg( all( test, feature = "benchmarks" ) ) ]
350
358
mod bench {
You can’t perform that action at this time.
0 commit comments