modular / modular/modular

[Feature Request] Add extend overload (mut other: Self)

Open
#7,147 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug_feature_triaged enhancement mojo Team: Mojo Libraries
Dominant language
Mojo
Stars
29.8k
Forks
3.2k
PR merge metrics
No merged PRs in 30d

Description

Review Mojo's priorities
What is your request?

For reference: https://doc.rust-lang.org/stable/std/vec/struct.Vec.html#method.append
The overload would memmove like the var version, but not deallocate other but rather set its len to 0 and preserve the capacity.
Most of the existing infra could be shared in a private method.

What is your motivation for this change?

Reusing old allocations is a common optimzation known in Rust and C++.

Any other details?

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the existing var-form extend implementation and compare its behavior with Rust's Vec::append reference. Implement the mut other: Self overload so elements move, other is left with length 0, and its capacity is preserved; reuse the existing infrastructure where appropriate.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, rust
Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.