123456789101112131415161718192021 |
- package types
- type Const[V any] struct {
- value V
- }
- // Create the new constant value.
- // Constant in the meaning you cannot ASSIGN
- // the lower lying value, not immutable thing.
- // Should think of how to make immutable stuff.
- func NewConst[V any](value V) Const[V] {
- return Const[V]{
- value: value,
- }
- }
- // Getting the constant value from the
- // pointer so the struct must be in the memory already. (initialized as variable)
- func (c *Const[V]) Get() V {
- return c.value
- }
|