-
Notifications
You must be signed in to change notification settings - Fork 842
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More trivial implementation of Box<dyn AsyncArrowWriter>
and Box<dyn AsyncArrowReader>
#6748
Conversation
…wReader> in parquet
Box<dyn Async Arrow Writer>
and Box<dyn AsyncArrowReader>
Box<dyn Async Arrow Writer>
and Box<dyn AsyncArrowReader>
Box<dyn AsyncArrowWriter>
and Box<dyn AsyncArrowReader>
I think adding |
It is not the same, but a superset of it. |
I'm still not convinced why we need to add lifetime for it. 👀 It would be clear if there is an example that compilation failed without lifetime |
Considering this case: pub struct ArrowReader<'reader, T> {
reader: &'reader T,
}
impl<T: AsyncFileReader + Send + Sync> AsyncFileReader for ArrowReader<'_, T> {
fn get_bytes(
&mut self,
range: std::ops::Range<usize>,
) -> std::pin::Pin<
Box<dyn std::future::Future<Output = parquet::errors::Result<bytes::Bytes>> + Send + '_>,
> {
todo!()
}
fn get_metadata(
&mut self,
) -> std::pin::Pin<
Box<
dyn std::future::Future<
Output = parquet::errors::Result<Arc<parquet::file::metadata::ParquetMetaData>>,
> + Send
+ '_,
>,
> {
todo!()
}
}
fn test<'r, T: AsyncFileReader + Send + Sync>(
file: ArrowReader<'r, T>,
) -> impl AsyncFileReader + 'r {
Box::new(file) as Box<dyn AsyncFileReader>
}
|
Actually it does have one lifetime in the current: If you are still confused, there is a basic explanation about it:
// Implemented for all lifetimes
impl Two for Box<dyn Trait + '_> {}
// Implemented for all lifetimes such that the inner lifetime is
// at least as long as the outer lifetime
impl Two for &(dyn Trait + '_) {} |
Co-authored-by: Jay Zhan <[email protected]>
In the current,
equals to
which
'static
bound is not necessary, for all'a
,Box<dyn AsyncFileReader + 'a>
should be anAsyncFileReader
. I removed this bound to make it more trivial