Repository navigation
Stop implementing methods on SImpl - #696
Merged
Merged
Conversation
lucic71
marked this pull request as draft
December 3, 2026 11:24
lucic71
marked this pull request as ready for review
December 3, 2026 11:37
Contributor
Author
|
Did the same for unsafe |
nunoplopes
pushed a commit
that referenced
this pull request
Dec 3, 2026
Depends on #696 C++ [offers](https://eel.is/c++draft/concept.equalitycomparable) WeaklyEqualityComparableWith, EqualityComparable, EqualityComparableWith. The relationship between them is: ```rs pub trait WeaklyEqualityComparableWith<U: WeaklyEqualityComparableWith<Self> = Self>: Sized { fn equal(this: Ptr<Self>, rhs: Ptr<U>) -> bool; // t == u fn not_equal(this: Ptr<Self>, rhs: Ptr<U>) -> bool { !Self::equal(this, rhs) } // t != u } pub trait EqualityComparable: WeaklyEqualityComparableWith<Self> {} impl<T: WeaklyEqualityComparableWith<T>> EqualityComparable for T {} pub trait EqualityComparableWith<U: EqualityComparable + WeaklyEqualityComparableWith<Self>>: EqualityComparable + WeaklyEqualityComparableWith<U> {} impl<T, U> EqualityComparableWith<U> for T where T: EqualityComparable + WeaklyEqualityComparableWith<U>, U: EqualityComparable + WeaklyEqualityComparableWith<T>, {} ``` --- std::find now is written as: ```cpp template <class T1, class T2> T1 f3(T1 first, T1 last, const T2 &value) { return std::find(first, last, value); } ``` to ```rs unsafe fn f3< T1: UnsafeCppInputIterator<T3>, T2: WeaklyEqualityComparableWithUnsafe<T3>, T3: WeaklyEqualityComparableWithUnsafe<T2>, >(a0: T1, a1: T1, a2: T2) -> T1 { ``` --- CppInputIterator is now bounded on EqualityComparable: `pub trait CppInputIterator<T>: CppIterator<T> + EqualityComparable {}`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before:
After:
Taking a
&Ptr<Self>as the receiver was wrong because it aliased with the arguments of the function, so I moved toPtr<Self>. This also has the nice side-effect that we can write onlyimpl Sinstead oftrait SImpl + impl Simpl for Ptr<Self>.