@@ -61,7 +61,13 @@ pub fn gen_simple_class(c: &Class, opencv_version: &str) -> String {
6161 ( "fields" , & fields) ,
6262 (
6363 "impl" ,
64- & gen_impl ( c, const_methods. iter ( ) . chain ( mut_methods. iter ( ) ) , & rust_local, opencv_version) ,
64+ & gen_impl (
65+ c,
66+ const_methods. iter ( ) . chain ( mut_methods. iter ( ) ) ,
67+ & rust_local,
68+ "" ,
69+ opencv_version,
70+ ) ,
6571 ) ,
6672 ( "impls" , & impls) ,
6773 ] ) )
@@ -89,6 +95,15 @@ pub fn gen_boxed_class(c: &Class, opencv_version: &str) -> String {
8995 const_methods. extend ( more_const_methods) ;
9096 mut_methods. extend ( more_mut_methods) ;
9197
98+ let lt = c. rust_lifetime ( ) ;
99+ let rust_decl_lt = lt. map_or_else ( || "" . to_string ( ) , |lt| format ! ( "<{}>" , lt. to_explicit( ) ) ) ;
100+ let rust_decl_for_lt = lt. map_or_else ( || "" . to_string ( ) , |lt| format ! ( ": for <{}>" , lt. to_explicit( ) ) ) ;
101+ let rust_elided_lt = lt. map_or_else ( || "" . to_string ( ) , |_| "<'_>" . to_string ( ) ) ;
102+ let rust_phantom_ref = lt. map_or_else (
103+ || "" . to_string ( ) ,
104+ |lt| format ! ( "_d: PhantomData<&{} mut ()>," , lt. to_explicit( ) ) ,
105+ ) ;
106+
92107 let type_ref = c. type_ref ( ) ;
93108 let bases = c. bases ( ) ;
94109
@@ -128,7 +143,8 @@ pub fn gen_boxed_class(c: &Class, opencv_version: &str) -> String {
128143 "base_rust_full_const" ,
129144 & base. rust_trait_name ( NameStyle :: ref_ ( ) , Constness :: Const ) ,
130145 ) ,
131- ( "rust_local" , & type_ref. rust_name ( NameStyle :: decl ( ) ) ) ,
146+ ( "rust_local" , & rust_local) ,
147+ ( "rust_elided_lt" , & rust_elided_lt) ,
132148 ( "rust_as_raw_const" , & base. rust_as_raw_name ( Constness :: Const ) ) ,
133149 ( "rust_as_raw_mut" , & base. rust_as_raw_name ( Constness :: Mut ) ) ,
134150 (
@@ -164,6 +180,10 @@ pub fn gen_boxed_class(c: &Class, opencv_version: &str) -> String {
164180 ( "doc_comment" , c. rendered_doc_comment ( "///" , opencv_version) . as_str ( ) ) ,
165181 ( "debug" , & c. get_debug ( ) ) ,
166182 ( "rust_local" , & rust_local) ,
183+ ( "rust_decl_lt" , & rust_decl_lt) ,
184+ ( "rust_decl_for_lt" , & rust_decl_for_lt) ,
185+ ( "rust_elided_lt" , & rust_elided_lt) ,
186+ ( "rust_phantom_ref" , & rust_phantom_ref) ,
167187 ( "rust_full" , & c. rust_name ( NameStyle :: ref_ ( ) ) ) ,
168188 (
169189 "rust_extern_const" ,
@@ -179,7 +199,7 @@ pub fn gen_boxed_class(c: &Class, opencv_version: &str) -> String {
179199 ( "traits" , & traits) ,
180200 ( "extern_delete" , & extern_delete) ,
181201 ( "bases" , & bases) ,
182- ( "impl" , & gen_impl ( c, methods, & rust_local, opencv_version) ) ,
202+ ( "impl" , & gen_impl ( c, methods, & rust_local, & rust_decl_lt , opencv_version) ) ,
183203 ( "impls" , & impls) ,
184204 ] ) )
185205}
@@ -296,7 +316,13 @@ fn all_methods_const_mut<'tu, 'ge>(c: &Class<'tu, 'ge>) -> (Vec<Func<'tu, 'ge>>,
296316 ( const_methods, mut_methods)
297317}
298318
299- fn gen_impl < ' f > ( c : & Class , methods : impl Iterator < Item = & ' f Func < ' f , ' f > > , rust_local : & str , opencv_version : & str ) -> String {
319+ fn gen_impl < ' f > (
320+ c : & Class ,
321+ methods : impl Iterator < Item = & ' f Func < ' f , ' f > > ,
322+ rust_local : & str ,
323+ rust_decl_lt : & str ,
324+ opencv_version : & str ,
325+ ) -> String {
300326 static IMPL_TPL : Lazy < CompiledInterpolation > = Lazy :: new ( || include_str ! ( "../tpl/class/impl.tpl.rs" ) . compile_interpolation ( ) ) ;
301327
302328 let consts = c. consts ( ) . iter ( ) . map ( |c| c. gen_rust ( opencv_version) ) . join ( "" ) ;
@@ -310,6 +336,7 @@ fn gen_impl<'f>(c: &Class, methods: impl Iterator<Item = &'f Func<'f, 'f>>, rust
310336 } else {
311337 IMPL_TPL . interpolate ( & HashMap :: from ( [
312338 ( "rust_local" , rust_local) ,
339+ ( "rust_decl_lt" , rust_decl_lt) ,
313340 ( "consts" , & consts) ,
314341 ( "inherent_methods" , & inherent_methods) ,
315342 ] ) )
0 commit comments