Skip to content

feature request: add convenient [] operator to std::vec::Vec #13031

Closed

Description

Dear Developers,

Rust language occurred to be amazingly suitable for many programming tasks.
For example, I successfully completed in Rust Coursera Illinois VLSI CAD: Logic to Layout one of the programming assignments and going to use Rust for the others.
Unfortunately after recent changes to the language the Rust code for the completed assignment occurred to be broken. No problem with it as the language evolves.

But the following constructs proposed for the new vec_ng::Vec design (below) v.get(1) and especially *v.get_mut(1) instead of used to be [] are bulky and over-complicated in my opinion:

use std::io::println;
use std::vec::Vec;

fn main()
{
    let mut v = vec!(1, 2, 3);
    //let elem = v[1];
    let elem = v.get(1);
    //v[1] = 4;
    *v.get_mut(1) = 4;
}

Could you please add more usual [] index access to std::vec_ng::Vec design?
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions