Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add insert and remove methods to vec::MutableVector<T> ? #4028

Closed
Dretch opened this issue Nov 24, 2012 · 1 comment
Closed

Add insert and remove methods to vec::MutableVector<T> ? #4028

Dretch opened this issue Nov 24, 2012 · 1 comment
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one.

Comments

@Dretch
Copy link
Contributor

Dretch commented Nov 24, 2012

I think it would be useful to have functions to insert and remove items from arbitrary positions within a mutable vec.

In other words, to integrate this trait into vec::MutableVector;

pub trait VecInsertRemove<T> {

    /// Insert an element at position i within self, shifting all
    /// elements after position i one position to the right.
    fn insert(&mut self, i: uint, x:T);

    /// Remove the element at position i within self, shifting all
    /// elements after position i one position to the left.
    fn remove(&mut self, i: uint) -> T;

}

Is this desirable? I can send a pull request with these additions plus tests.

@catamorphism
Copy link
Contributor

Fixed in 689f6ce -- thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

No branches or pull requests

2 participants