Skip to content
This repository was archived by the owner on Feb 8, 2024. It is now read-only.
This repository was archived by the owner on Feb 8, 2024. It is now read-only.

Optional fields rewrite #11

@Terisback

Description

@Terisback

At the moment, optional fields in structures are not implemented in vlang, but as far as I understand this is a matter of time. We can try to implement our own through generics:

struct None {}
type OptError = string | None
struct Opt<T> {
    value T
    error OptError = None{}
}

struct MessageModify {
    text Opt<string>
}

editQuery := MessageModify{Opt<string>{value: 'Hello there!'})
// Then in rest method check every field error and serialize

Options will replace almost all fields in already written structures

or do nothing yet and wait for implementation in language

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions