File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 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]> {
323323/// A convenience type that can be used in a constant or static.
324324pub type ByteSubstringConst = ByteSubstring < & ' static [ u8 ] > ;
325325
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 > ) ;
328328
329- impl < ' a > Substring < ' a > {
329+ impl < ' a > Substring < & ' a [ u8 ] > {
330330 pub /* const */ fn new ( needle : & ' a str ) -> Self {
331331 Substring ( ByteSubstring :: new ( needle. as_bytes ( ) ) )
332332 }
333+ }
334+
335+ impl Substring < Vec < u8 > > {
336+ pub fn new_owned ( needle : String ) -> Self {
337+ Substring ( ByteSubstring :: new ( needle. into_bytes ( ) ) )
338+ }
339+ }
333340
341+ impl < T > Substring < T > where T : AsRef < [ u8 ] > {
334342 #[ cfg( feature = "pattern" ) ]
335343 fn needle_len ( & self ) -> usize {
336344 self . 0 . needle_len ( )
@@ -344,7 +352,7 @@ impl<'a> Substring<'a> {
344352}
345353
346354/// 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 > ;
348356
349357#[ cfg( all( test, feature = "benchmarks" ) ) ]
350358mod bench {
You can’t perform that action at this time.
0 commit comments