You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add Push::size_hint and VecPush terminal operator [ci-bench]
Added `size_hint(self: Pin<&mut Self>, hint: (usize, Option<usize>))` to the
`Push` trait as the push-side analog of `Pull::size_hint`. This allows
producers to announce how many items they're about to send, enabling
downstream operators and sinks to pre-allocate.
Trait changes:
- `Push::size_hint`: default no-op implementation
- `&mut P` blanket impl: forwards to inner
- `PushVariadic::size_hint`: new required method
Propagation through combinators:
- Map, Inspect: pass through unchanged (1:1 mapping)
- Filter, FilterMap: lower bound set to 0, upper preserved
- FlatMap, Flatten: hint becomes (0, None) — output count unknown
- Fanout, Unzip: forward to both branches
- Persist: reserves on internal Vec buffer, then forwards
- DemuxVar: forwards to all downstream pushes via PushVariadic
- ForEach, SinkPush, ResolveFutures: use default no-op
New terminal operator:
- `VecPush<Buf>`: pushes items into a `Vec`, uses `size_hint` to call
`Vec::reserve(hint.0)` for pre-allocation. Gated on `alloc` feature.
- Constructor: `push::vec_push(buf)` creates a VecPush from a `&mut Vec<T>`.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
let __ctx = <<#variant_generics_push as #root::dfir_pipes::push::Push<#variant_output_types,()>>::Ctx<'_> as #root::dfir_pipes::Context<'_>>::unmerge_self(__ctx);
let __ctx = <<#variant_generics_push as #root::dfir_pipes::push::Push<#variant_output_types,()>>::Ctx<'_> as #root::dfir_pipes::Context<'_>>::unmerge_other(__ctx);
398
396
)*
399
-
let #lastvar = #root::dfir_pipes::push::Push::#method_name(#lastvar.as_mut(), __ctx);
397
+
let #lastvar = #root::dfir_pipes::push::Push::#method_name(::std::pin::Pin::as_mut(#lastvar), __ctx);
0 commit comments