mbrobbel commented on code in PR #8227:
URL: https://github.com/apache/arrow-rs/pull/8227#discussion_r2328608065
##########
arrow-cast/src/pretty.rs:
##########
@@ -60,7 +60,7 @@ use crate::display::{ArrayFormatter, FormatOptions};
/// | 5 | e |
/// +---+---+"#);
/// ```
-pub fn pretty_format_batches(results: &[RecordBatch]) -> Result<impl Display,
ArrowError> {
+pub fn pretty_format_batches(results: &[RecordBatch]) -> Result<impl Display +
use<>, ArrowError> {
Review Comment:
The relevant change is documented here
https://doc.rust-lang.org/edition-guide/rust-2024/rpit-lifetime-capture.html
> In Rust 2021 and earlier editions, when the use<..> bound is not present,
generic lifetime parameters are only captured when they appear syntactically
within a bound in RPIT opaque types in the signature of bare functions and
associated functions and methods within inherent impls. However, starting in
Rust 2024, these in-scope generic lifetime parameters are unconditionally
captured.
The returned type does not capture the lifetime of the recordbatch slice, so
`use<>` indicates this.
For users this means that the following still compiles in 2024 Rust:
```rust
let record_batches: &[RecordBatch] = ...;
let pretty = pretty_format_batches(record_batches)?;
drop(record_batches);
dbg!(pretty);
```
Without `use<>` in 2024 Rust `rustc` would complain about `record_batches`
still being borrowed when dropped.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]