Skip to content

cxx-qt-lib: mirror PartialEq impls added in the previous commit - #1484

Closed
yuknig wants to merge 1 commit into
KDAB:mainfrom
yuknig:qlist_partial_eq_rhs
Closed

cxx-qt-lib: mirror PartialEq impls added in the previous commit#1484
yuknig wants to merge 1 commit into
KDAB:mainfrom
yuknig:qlist_partial_eq_rhs

Conversation

@yuknig

@yuknig yuknig commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

so that QList operand may appear on either side of an equality comparison.

@codecov

codecov Bot commented Aug 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (90d7b2c) to head (64e89d1).

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

☔ View full report in Codecov by Harness.
📢 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.

Comment thread crates/cxx-qt-lib/src/core/qlist/mod.rs Outdated
so that QList operand may appear on either side of an equality comparison.
@yuknig
yuknig force-pushed the qlist_partial_eq_rhs branch from 0e22168 to 64e89d1 Compare August 18, 2026 13:02

@ahayzen-kdab ahayzen-kdab left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, a bit unfortunate that because the types are different we need this reversal.

I guess another simpler way could be instead to make a as_slice(&self) -> &[T] method like Vec has then you could do like &[1,2] == list.as_slice().

I note that when looking at Vec<T> against &[T] it only allows you to compare a vec to slice and not slice to vec ? Instead you can do as_slice() to cause a slice to slice comparison which then works

@yuknig So i wonder if we should do the same here, keep only the PartialEq you have in the previous change and then add as_slice(), this would then be consistent with how a Vec works in std i think ?

@yuknig

yuknig commented Aug 18, 2026

Copy link
Copy Markdown
Contributor Author

@ahayzen-kdab I'm afraid we can't implement as_slice() for QList with Qt 5. As I understand the documentation, QList does not guarantee a contiguous memory layout like one in Vec. It might have something like linked list layout:

Note: QVector and QVarLengthArray both guarantee C-compatible array layout. QList does not. This might be important if your application must interface with a C API.

UPD: The lack of data() and constData() functions in QList in Qt 5 also hints that we should not rely on contiguity of the memory storage.

@ahayzen-kdab

ahayzen-kdab commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

@ahayzen-kdab I'm afraid we can't implement as_slice() for QList with Qt 5. As I understand the documentation, QList does not guarantee a contiguous memory layout like one in Vec. It might have something like linked list layout:

Note: QVector and QVarLengthArray both guarantee C-compatible array layout. QList does not. This might be important if your application must interface with a C API.

UPD: The lack of data() and constData() functions in QList in Qt 5 also hints that we should not rely on contiguity of the memory storage.

@yuknig right in Qt 5 a Qt 6 QList is actually a QVector so likely put as_slice() if possible (?) only for Qt 6 to QList, and in theory would be added to QVector too. But tbh Qt 5 is EOL anyway so it's a matter of just keeping it building not blocking new features because of it so using the cfg flags like we do elsewhere is the route. Or whether we just ignore this feature entirely as Rust std doesn't tend to implement reverse PartialEq like this from what i can see ?

@yuknig

yuknig commented Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

Yes, I think I can adapt codebase on the client side codebase so that it compiles without this change.

@yuknig yuknig closed this Aug 20, 2026
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.

2 participants