@@ -7,15 +7,14 @@ use crate::{
77use num_traits:: { cast:: ToPrimitive , sign:: Signed } ;
88
99#[ derive( FromArgs ) ]
10- pub struct SplitArgs < ' s , T : TryFromObject + AnyStrWrapper < ' s > > {
10+ pub struct SplitArgs < T : TryFromObject + AnyStrWrapper > {
1111 #[ pyarg( any, default ) ]
1212 sep : Option < T > ,
1313 #[ pyarg( any, default = "-1" ) ]
1414 maxsplit : isize ,
15- _phantom : std:: marker:: PhantomData < & ' s ( ) > ,
1615}
1716
18- impl < ' s , T : TryFromObject + AnyStrWrapper < ' s > > SplitArgs < ' s , T > {
17+ impl < T : TryFromObject + AnyStrWrapper > SplitArgs < T > {
1918 pub fn get_value ( self , vm : & VirtualMachine ) -> PyResult < ( Option < T > , isize ) > {
2019 let sep = if let Some ( s) = self . sep {
2120 let sep = s. as_ref ( ) ;
@@ -69,10 +68,10 @@ impl StartsEndsWithArgs {
6968 }
7069
7170 #[ inline]
72- pub fn prepare < ' s , S , F > ( self , s : & ' s S , len : usize , substr : F ) -> Option < ( PyObjectRef , & ' s S ) >
71+ pub fn prepare < S , F > ( self , s : & S , len : usize , substr : F ) -> Option < ( PyObjectRef , & S ) >
7372 where
74- S : ?Sized + AnyStr < ' s > ,
75- F : Fn ( & ' s S , std:: ops:: Range < usize > ) -> & ' s S ,
73+ S : ?Sized + AnyStr ,
74+ F : Fn ( & S , std:: ops:: Range < usize > ) -> & S ,
7675 {
7776 let ( affix, range) = self . get_value ( len) ;
7877 let substr = if let Some ( range) = range {
@@ -133,8 +132,8 @@ impl StringRange for std::ops::Range<usize> {
133132 }
134133}
135134
136- pub trait AnyStrWrapper < ' s > {
137- type Str : ?Sized + AnyStr < ' s > ;
135+ pub trait AnyStrWrapper {
136+ type Str : ?Sized + AnyStr ;
138137 fn as_ref ( & self ) -> & Self :: Str ;
139138}
140139
@@ -147,20 +146,23 @@ where
147146 fn push_str ( & mut self , s : & S ) ;
148147}
149148
150- // TODO: GATs for `'s` once stabilized
151- pub trait AnyStr < ' s > : ' s {
149+ pub trait AnyStr {
152150 type Char : Copy ;
153151 type Container : AnyStrContainer < Self > + Extend < Self :: Char > ;
154- type CharIter : Iterator < Item = char > + ' s ;
155- type ElementIter : Iterator < Item = Self :: Char > + ' s ;
152+ type CharIter < ' a > : Iterator < Item = char > + ' a
153+ where
154+ Self : ' a ;
155+ type ElementIter < ' a > : Iterator < Item = Self :: Char > + ' a
156+ where
157+ Self : ' a ;
156158
157159 fn element_bytes_len ( c : Self :: Char ) -> usize ;
158160
159161 fn to_container ( & self ) -> Self :: Container ;
160162 fn as_bytes ( & self ) -> & [ u8 ] ;
161163 fn as_utf8_str ( & self ) -> Result < & str , std:: str:: Utf8Error > ;
162- fn chars ( & ' s self ) -> Self :: CharIter ;
163- fn elements ( & ' s self ) -> Self :: ElementIter ;
164+ fn chars ( & self ) -> Self :: CharIter < ' _ > ;
165+ fn elements ( & self ) -> Self :: ElementIter < ' _ > ;
164166 fn get_bytes ( & self , range : std:: ops:: Range < usize > ) -> & Self ;
165167 // FIXME: get_chars is expensive for str
166168 fn get_chars ( & self , range : std:: ops:: Range < usize > ) -> & Self ;
@@ -179,14 +181,14 @@ pub trait AnyStr<'s>: 's {
179181
180182 fn py_split < T , SP , SN , SW , R > (
181183 & self ,
182- args : SplitArgs < ' s , T > ,
184+ args : SplitArgs < T > ,
183185 vm : & VirtualMachine ,
184186 split : SP ,
185187 splitn : SN ,
186188 splitw : SW ,
187189 ) -> PyResult < Vec < R > >
188190 where
189- T : TryFromObject + AnyStrWrapper < ' s , Str = Self > ,
191+ T : TryFromObject + AnyStrWrapper < Str = Self > ,
190192 SP : Fn ( & Self , & Self , & VirtualMachine ) -> Vec < R > ,
191193 SN : Fn ( & Self , & Self , usize , & VirtualMachine ) -> Vec < R > ,
192194 SW : Fn ( & Self , isize , & VirtualMachine ) -> Vec < R > ,
@@ -247,7 +249,7 @@ pub trait AnyStr<'s>: 's {
247249 func_default : FD ,
248250 ) -> & ' a Self
249251 where
250- S : AnyStrWrapper < ' s , Str = Self > ,
252+ S : AnyStrWrapper < Str = Self > ,
251253 FC : Fn ( & ' a Self , & Self ) -> & ' a Self ,
252254 FD : Fn ( & ' a Self ) -> & ' a Self ,
253255 {
@@ -308,10 +310,10 @@ pub trait AnyStr<'s>: 's {
308310 self . py_pad ( width - len, 0 , fillchar)
309311 }
310312
311- fn py_join < ' a > (
313+ fn py_join (
312314 & self ,
313315 mut iter : impl std:: iter:: Iterator <
314- Item = PyResult < impl AnyStrWrapper < ' s , Str = Self > + TryFromObject > ,
316+ Item = PyResult < impl AnyStrWrapper < Str = Self > + TryFromObject > ,
315317 > ,
316318 ) -> PyResult < Self :: Container > {
317319 let mut joined = if let Some ( elem) = iter. next ( ) {
@@ -413,7 +415,7 @@ pub trait AnyStr<'s>: 's {
413415 rustpython_common:: str:: zfill ( self . as_bytes ( ) , width)
414416 }
415417
416- fn py_iscase < F , G > ( & ' s self , is_case : F , is_opposite : G ) -> bool
418+ fn py_iscase < F , G > ( & self , is_case : F , is_opposite : G ) -> bool
417419 where
418420 F : Fn ( char ) -> bool ,
419421 G : Fn ( char ) -> bool ,
0 commit comments