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

Optional fields rewrite #11

Open
Terisback opened this issue Jan 11, 2021 · 1 comment
Open

Optional fields rewrite #11

Terisback opened this issue Jan 11, 2021 · 1 comment

Comments

@Terisback
Copy link
Owner

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

@Terisback Terisback changed the title Idea how to realize REST optional fields and generally optional parameters Optional fields rewrite Jan 16, 2021
@Terisback
Copy link
Owner Author

Now we are just waiting for the implementation of optional fields in structures

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant