felipecrv opened a new issue, #2694: URL: https://github.com/apache/arrow-adbc/issues/2694
### What feature or improvement would you like to see? (PR #2693 has code illustrating this problem and a candidate solution) When I try to make a Box'd `RecordBatchReader`, the compiler complains because there is a possibility that the `impl RecordBatchReader` returned might be holding any of `&` passed in the parameters:  When I'm forced to be explicit about lifetimes, I end up with: ```rust struct BoxedReaderConnection(DummyConnection); impl BoxedReaderConnection { pub fn get_objects<'a>( &'a self, depth: ObjectDepth, catalog: Option<&'a str>, db_schema: Option<&'a str>, table_name: Option<&'a str>, table_type: Option<Vec<&'a str>>, column_name: Option<&'a str>, ) -> Result<Box<dyn RecordBatchReader + Send + 'a>> { let reader = self.0.get_objects( depth, catalog, db_schema, table_name, table_type, column_name, )?; let boxed_reader: Box<dyn RecordBatchReader + Send + 'a> = Box::new(reader); Ok(boxed_reader) } } ``` This is not ideal because I don't want to tie the lifetime of `table_name: Option<&'a str>` to the lifetime of the returned `RecordBatchReader`. So I believe the proper solution is to change the `adbc_core` traits to explicitly declare that the `RecordBatchReader` can outlive the input references. Like this: ```rust fn get_objects<'a>( &'_ self, depth: options::ObjectDepth, catalog: Option<&'_ str>, db_schema: Option<&'_ str>, table_name: Option<&'_ str>, table_type: Option<Vec<&'_ str>>, column_name: Option<&'_ str>, ) -> Result<impl RecordBatchReader + Send + 'a>; ``` allowing a wrapper that boxes the `RecordBatchReader` to be written as ```rust impl BoxedReaderConnection { pub fn get_objects<'a>( &'_ self, depth: ObjectDepth, catalog: Option<&'_ str>, db_schema: Option<&'_ str>, table_name: Option<&'_ str>, table_type: Option<Vec<&'_ str>>, column_name: Option<&'_ str>, ) -> Result<Box<dyn RecordBatchReader + Send>> { let reader = self.0.get_objects( depth, catalog, db_schema, table_name, table_type, column_name, )?; let boxed_reader = Box::new(reader); Ok(boxed_reader) } } ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@arrow.apache.org.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org