Skip to content

[Feature Request] Generate getter/setter for all/multiple fields #13246

Open
@Zerowalker

Description

@Zerowalker

Not sure if this is "easy" to implement, tried looking at the code and it looks to be limited to 1 "item".
But will ask nevertheless in case I'm wrong:)

So say you got:

pub struct Foo {
    alpha: u32,
    bar: u32,
    beta: u32,
    gamma: u32,
}

It would be nice if you could have the action generate getter/setter for all fields and/or multiple fields,
perhaps selected in the editor, though it feels a bit hacky as they might not be in order.

So if you did generate getter/setter for all fields it would end up with asking you the: generate a X method,
and if we chose generate a getter method it would end up as:

pub struct Foo {
    alpha: u32,
    bar: u32,
    beta: u32,
    gamma: u32,
}

impl Foo {
    pub fn alpha(&self) -> u32 {
        self.alpha
    }

    pub fn bar(&self) -> u32 {
        self.bar
    }

    pub fn beta(&self) -> u32 {
        self.beta
    }

    pub fn gamma(&self) -> u32 {
        self.gamma
    }
}

It's just a "simple" convenience and i completely understand it's uses are small so I'm pushing hard for it just a simple request:)

Thanks everyone contributing to this project, all your work is very much appreciated!

Metadata

Metadata

Assignees

Labels

A-assistsC-featureCategory: feature requestS-actionableSomeone could pick this issue up and work on it right now

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions