pulse-binding-rust
pulse-binding-rust copied to clipboard
Derive Clone for SinkInfo and SinkPortInfo
The Clone
implementation enables using data from a SinkInfo
outside the callback functions where a reference to one is made available
Hm, because of how Clone
is implemented for Cow
this would have to do Cow::Owned(field.clone().into_owned())
on every field with a Cow
to work the way I had in mind.
I've also noticed that the API lacks something like this.
I guess changing it into an owned value doesn't really have the expected semantics of a Clone
, to_owned
means something a bit different, and into_owned
would be expected to take self
...
Maybe derive Clone
, but also have an into_owned(self) -> Self<'static>
method to match Cow
? Looks like something like https://crates.io/crates/derive-into-owned could derive that automatically.
Or... I see you already mentioned that same crate on https://github.com/jnqnfe/pulse-binding-rust/issues/44.
There is a bit of complexity in SinkInfo
since it has Option<Cow<_>>
fields and a Vec<SinkPortInfo<'a>>
field where SinkPortInfo
also contains Cow
types. It may require a custom macro (or maybe improvements could be made to derive-into-owned
)?