Skip to content

Derive Default for some types? #13

@virtualritz

Description

@virtualritz

The example uses a non-idiomatic way to initialize Message that requires mut.

Idiomatic would be either the builder- or the init-struct-pattern. The former is a lot of boilerplate while the latter requires only the Default trait.

I.e. instead of:

    // Create a message.
    let mut message = Message {
        vec![Destination::new("+436764162755")]
    );
    message.text = Some("Foobar!".to_string());

this:

    // Create a message.
    let message = Message {
        destinations: Some(vec![Destination::new("123456789")]),
        text: Some("Foobar!".to_string()),
        ..Default::default(),
    );

Metadata

Metadata

Assignees

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