drm-rs icon indicating copy to clipboard operation
drm-rs copied to clipboard

[API Break] Make `control::property::Info::value_type` return `&` instead of clone

Open ids1024 opened this issue 10 months ago • 2 comments

It seems odd for this to return an owned value, when ::name() doesn't. And it is useful to get a reference to the ValueType, so ValueType::convert_value can be used and just use the lifetime of the Info instead of the cloned ValueType.

I assume there's no reason not to do this, since callers can still clone as needed.

As a small API break, I think this should be merged whenever the next semver bump to the crate happens to be.

ids1024 avatar Mar 06 '25 18:03 ids1024

It was probably intended as a cheap Copy type, except that the presence of EnumValues (with Vecs) no longer makes that cheaply possible?

MarijnS95 avatar Mar 06 '25 21:03 MarijnS95

Yeah, I was wondering about that, but haven't check the history. If it were a Copy type the current API would be good, but not now that it contains a couple Vecs (if it's an enum), and Value<'_> holds a reference to it.

ids1024 avatar Mar 06 '25 22:03 ids1024

I think this is a good change, is this ready for merge?

Drakulix avatar Jul 25 '25 15:07 Drakulix

I think the only reason I marked this as a draft is because it's a breaking change. So if there's going to be a breaking release, it should be mergable.

ids1024 avatar Jul 25 '25 16:07 ids1024

Didn't we already land a bunch of breaking changes? This can probably be merged after a rebase, I don't see the CI being unhappy with it after that :)

MarijnS95 avatar Jul 26 '25 19:07 MarijnS95

yeah, I think this just needs a rebase

Drakulix avatar Jul 28 '25 15:07 Drakulix

CI passing, after also updating a line in planes example.

ids1024 avatar Jul 29 '25 16:07 ids1024

thx!

Drakulix avatar Jul 30 '25 11:07 Drakulix