nats.rs icon indicating copy to clipboard operation
nats.rs copied to clipboard

ConnectOptions do not implement Clone

Open matthiasbeyer opened this issue 1 year ago • 1 comments

Use Case:

In some instances it might be nice to have a Clone implementation for ConnectOptions.

Proposed Change:

Right now it seems possible, only the event_callback: CallbackArg1 member is an issue.

Who Benefits From The Change(s)?

In instances where the user of the crate uses a framework that does configuration construction in one step, and a later step is responsible for the connect() call. If the user only has a nonmutable reference to the constructed ConnectOptions instance in that moment, they have to use some Arc/Mutex trickery to make their code work.

Alternative Approaches

Arc/Mutex trickery or "manual cloning" of a ConnectOptions instance.

matthiasbeyer avatar Apr 11 '23 15:04 matthiasbeyer

+1 for this!

esemeniuc avatar Nov 14 '23 19:11 esemeniuc