mirror of
https://github.com/pocket-id/pocket-id.git
synced 2025-12-22 09:15:41 +03:00
feat: add the ability to make email optional (#994)
This commit is contained in:
@@ -1,13 +1,16 @@
|
||||
package utils
|
||||
|
||||
// Ptr returns a pointer to the given value.
|
||||
func Ptr[T any](v T) *T {
|
||||
return &v
|
||||
}
|
||||
|
||||
func PtrValueOrZero[T any](ptr *T) T {
|
||||
if ptr == nil {
|
||||
var zero T
|
||||
return zero
|
||||
// PtrOrNil returns a pointer to v if v is not the zero value of its type,
|
||||
// otherwise it returns nil.
|
||||
func PtrOrNil[T comparable](v T) *T {
|
||||
var zero T
|
||||
if v == zero {
|
||||
return nil
|
||||
}
|
||||
return *ptr
|
||||
return &v
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user