Skip to content

Conversation

@jnbooth
Copy link
Contributor

@jnbooth jnbooth commented Dec 24, 2025

There's an odd pattern across many files that looks like this:

impl From<&QLine> for QLineF {
    fn from(line: &QLine) -> Self {
        ffi::qlinef_from_qline(line)
    }
}

impl From<QLineF> for QLine {
    fn from(value: QLineF) -> Self {
        value.to_line()
    }
}

One of the implementations uses a borrow, and the other one does not, even though both are calling functions that take references. Theoretically, in order to be consistent with Qt, both implementations should use borrowing (From<&QLine> and From<&QLineF>). But I don't think it would make sense to remove the by-value implementations, because A) that would be a breaking change, and B) it is useful to be able to do e.g. let pointf = QPoint::new(1, 2).into() rather than let pointf = (&QPoint::new(1, 2)).into(). So instead, I just added complementary implementations so now From<QLine> for QLineF and From<&QLineF> for QLine are implemented as well.

That said, I'm not sure why QPen implements From<&PenStyle>. I added an implementation for From<PenStyle>, so that part is handled, but at some point it might be worth removing the From<&PenStyle> implementation, because PenStyle is just an i32 enum. There's no point in passing it by reference rather than value.

@codecov
Copy link

codecov bot commented Dec 24, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (c98fb62) to head (35a6192).

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #1384   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           75        75           
  Lines        13108     13108           
=========================================
  Hits         13108     13108           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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