Skip to content

construct forward_list copies and moves directly from source - #72

Merged
teor2345 merged 1 commit into
rustfoundation:mainfrom
Siddhi-sahu:fix-forwardlist-copy--move
Nov 10, 2026
Merged

teor2345 merged 1 commit into
rustfoundation:mainfrom
Siddhi-sahu:fix-forwardlist-copy--move

Conversation

@Siddhi-sahu

@Siddhi-sahu Siddhi-sahu commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

While working on my stack pr, I noticed something in forward_list.rs. the move_from didnot actually call the move constructor. it moved list into other_ , and then built the new list from it. other_ has a name, sp cpp treats it as lvalue, so the the 2 line calls the copy constructor, and the &mut (move) overload is returning the new list, that is built by a copy.

same for copy_from , it has the same 2 steps : it basically copied into a a const local and copied it again, so it used the right constructor but made 2 copies .

Now: both, constructs the new list directly from *other , std::move(*other) , in one step, in forward_list.rs. Like in #62 .

Also, as @teor2345 guided, to look through Other merged classes, on main. I did that . But the unordered_map, unordered_multiset, time_point, already constructs directly.

Signed-off-by: Siddhi sahu <himanisahu739@gmail.com>

@teor2345 teor2345 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.

Thank you!

@teor2345
teor2345 enabled auto-merge November 10, 2026 20:54
@teor2345
teor2345 added this pull request to the merge queue Nov 10, 2026
Merged via the queue into rustfoundation:main with commit a02c5bb Nov 10, 2026
13 checks passed
@Siddhi-sahu

Copy link
Copy Markdown
Contributor Author

Thank you!

thank you for reviewing.

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