Skip to content

Comments

Tee implementation without Clone requirement#744

Draft
frankmcsherry wants to merge 9 commits intoTimelyDataflow:masterfrom
frankmcsherry:non_clone_tee
Draft

Tee implementation without Clone requirement#744
frankmcsherry wants to merge 9 commits intoTimelyDataflow:masterfrom
frankmcsherry:non_clone_tee

Conversation

@frankmcsherry
Copy link
Member

This is a bit of a proof of concept, stealing a bit from @antiguru's PR.

The goal is to support a Tee that does not have an inherent Clone requirement. Currently, the requirement exists because Tee itself is responsible for cloning containers when there are multiple consumers, and we need to have Tee to support any number of consumers.

The change here is to use a Box<dyn Push<T>> for the Tee, whose implementor either is or is not able to clone pushed containers, and handles that call without constraining Tee. The two implementors, PushOne and PushMany, respectively do not and do require Clone. The logic is set up so that the TeeHelper installs a PushMany only as the second pushee, and doing so could in principle live behind a method that has the C: Clone constraint.

It's not certain how to proceed, other than stealing further from @antiguru. Any concrete TeeHelper or StreamCore would need to either require Clone or not, and the ability to use it would depend on how we set that up. It seems "easy" to have two distinct types, but @antiguru reports that perhaps this is not necessary (the Streamlike trait not being required). Further investigation / copying is required!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant