File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -325,14 +325,25 @@ where
325325/// A convenience type that can be used in a constant or static.
326326pub type ByteSubstringConst = ByteSubstring < & ' static [ u8 ] > ;
327327
328- /// Searches a string for the first occurence of the substring.
329- pub struct Substring < ' a > ( ByteSubstring < & ' a [ u8 ] > ) ;
328+ /// Searches a string for the first occurrence of the substring.
329+ pub struct Substring < T > ( ByteSubstring < T > ) ;
330330
331- impl < ' a > Substring < ' a > {
331+ impl < ' a > Substring < & ' a [ u8 ] > {
332332 pub /* const */ fn new ( needle : & ' a str ) -> Self {
333333 Substring ( ByteSubstring :: new ( needle. as_bytes ( ) ) )
334334 }
335+ }
336+
337+ impl Substring < Vec < u8 > > {
338+ pub fn new_owned ( needle : String ) -> Self {
339+ Substring ( ByteSubstring :: new ( needle. into_bytes ( ) ) )
340+ }
341+ }
335342
343+ impl < T > Substring < T >
344+ where
345+ T : AsRef < [ u8 ] > ,
346+ {
336347 #[ cfg( feature = "pattern" ) ]
337348 fn needle_len ( & self ) -> usize {
338349 self . 0 . needle_len ( )
@@ -346,7 +357,7 @@ impl<'a> Substring<'a> {
346357}
347358
348359/// A convenience type that can be used in a constant or static.
349- pub type SubstringConst = Substring < ' static > ;
360+ pub type SubstringConst = Substring < & ' static str > ;
350361
351362#[ cfg( all( test, feature = "benchmarks" ) ) ]
352363mod bench {
You can’t perform that action at this time.
0 commit comments