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
a struct with channel and queue #25
Comments
I believe Consumer and Queue have different lifetimes from SomeConsumer? |
Yes, this is just a general pain point with structs and lifetimes; a struct cannot (easily) contain both an item and a reference to that item. I haven't tried, but you might be able to accomplish this with rental or owning_ref, which allow bundling of an owner and a reference to it together. |
Did anyone found a doable solution to this? Wanted to give this library a try, but this is a deal breaker I got stuck on... makes it hard to manage consumers and publishers in elegant way. |
The library currently doesn't support this kind of grouping without using something like A different design would be to have |
I wanted to create a constructor which setups and returns the following struct:
But since queue has reference to its Channel (which is the same as
chan
field), I believe it is not possible to create such struct?Lib's queue struct:
constructor:
This results in error:
So I tried to create a separate method for queue declaration so it would have a reference to channel after it has been moved:
And that gives another error:
The text was updated successfully, but these errors were encountered: