Repository navigation
Add std::list overloads: constructors, insert, erase, splice, sort - #58
Open
rogerkorantenng wants to merge 1 commit into
Open
rogerkorantenng wants to merge 1 commit into
rogerkorantenng wants to merge 1 commit into
Conversation
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.
Outreachy Application:
std::listoverloadsClaimed in #38 (#38 (comment)), from the tracking issue #19.
This PR wraps 5 overloaded
std::listmethod names incpp-overload-test/src/stdcpp/list.rs:new(constructors),insert,erase,spliceandsort. Every overload for each name is either wrapped or documented as skipped. The skipped ones are allocator variants and the&/&&duplicates.Interesting findings
insert,eraseandsplicetake a position from the same list as&mut self. IfStdListIterborrowed the list, you couldn't calllist.insert(&pos, ...)while holdingpos. So the iterator wraps aconst_iteratorand doesn't borrow the list. The cost is that Rust can't stop you using an iterator from the wrong list, or one that has been erased. C++ can't either. A cursor API would fix this, but theninsertwould be a cursor method instead of a list overload.new(3, 9)gives[3, 9](initializer list), butnew(3_usize, 9)gives[9, 9, 9]. Forget the suffix and you silently get the other overload. IfTwerec_size_t, these overloads would conflict (E0119).&vs&mut.new(&other)copies andnew(&mut other)emptiesother. That's easy to mix up.splicegoes from 6 overloads to 3.list&andlist&&both become&mut StdList. Splicing a list into itself is impossible, because it would need two&mutborrows. Moved elements' iterators now point intoself, which Rust lifetimes can't express.insert(pos, initializer_list)becomes a slice. The constructors' 1/2/3-item trick doesn't work here:insert(pos, a)has the same types asinsert(pos, value).sort(comp)needs anextern "C" fn. There are no generics inoverload!, and C++ templates can't be instantiated for a Rust closure type, so closures can't be passed (capturing or not). A panicking predicate aborts the process. A C++ trampoline plus a closure pointer could fix this.let list: StdList = StdList::new(...), even though every overload returnsStdList(marked FIXME).AI use
No, AI was used in writing the code, they were written and tested by myself with the help of the rust documentation(rustdoc)
Banned AI Usage
Do not use AI to write GitHub descriptions, GitHub comments, code comments, or Zulip chats. Write in your native language, or at your current English level. In your PR description, you must tell us how you used AI. You must review code yourself before you open a PR.
For the best learning experience, write the code yourself, without using AI. Using LLMs to generate code is heavily restricted, and generating large amounts of code is banned.
Applicants must follow the Rust Project AI/LLM policy.
Application Steps
Claim a C++ standard library type from the list in the tracking issue by clicking on that issue, then commenting on it. This is the C++ type you will be working on. Before you claim a ticket, make sure no-one else has commented before you.
After each step, push your work to your open PR, make sure CI passes, then wait for 2-4 days for a mentor to review it. If you need help, post a message in the #outreachy > Overloading Applicant Help Oct 2026 topic on Zulip.
This coding task focuses on Rust and C++ overloads. It is ok to skip drop/destructors (leak memory), use unsafe, and ignore some compiler warnings. Shortcuts and workarounds can be used to simplify non-overload code.
Checklist
cpp-overload-test/src/stdcppLimitationsdoc sectionErgonomicsdoc sectioncpp-overload-test/examplesIncompatibilitiesdoc sectionWorkaroundsdoc sectionInexpressible Overloadsdoc section