Skip to content

Improve fill_struct_fields assist #1470

@theduke

Description

@theduke

The Intellij plugin generates literals for some types when filling struct fields.

If I remember correctly, this is String::new() for strings, Vec::new() for vectors, 0 / 0.0 for numbers, false for bools.
I like this behaviour since it let's me know the type, and provides a valid initialization.

I checked the code and I'm happy to implement this, but I wanted to discuss desired semantics first.

Eg, strings could also be implemented as "".to_string() instead of String::new(). Similarly, Vec could be vec![]. This would make it easier to provide your own values.

For other types, we could check if the type implements Default, and use T::default().

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-assistsS-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