diff --git a/go.mod b/go.mod index fd0635b3..84609eb0 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/diamondburned/arikawa/v3 -go 1.16 +go 1.18 require ( github.com/gorilla/schema v1.4.1 diff --git a/utils/json/option/option.go b/utils/json/option/option.go index f192c289..95dd7126 100644 --- a/utils/json/option/option.go +++ b/utils/json/option/option.go @@ -4,3 +4,17 @@ // To generate pointerrized primitives, there are helper functions NewT() for // each option type. package option + +// Optional wraps a type to make it omittable. +type Optional[T any] *T + +// Some creates a new Optional with the value of the passed type. +func Some[T any](v T) Optional[T] { + return &v +} + +// PtrTo creates a pointer to the passed value. +// It is like [Some], except it returns *T directly rather than Optional[T]. +func PtrTo[T any](v T) *T { + return &v +}