mut.go 477 B

123456789101112131415161718192021
  1. package types
  2. type Const[V any] struct {
  3. value V
  4. }
  5. // Create the new constant value.
  6. // Constant in the meaning you cannot ASSIGN
  7. // the lower lying value, not immutable thing.
  8. // Should think of how to make immutable stuff.
  9. func NewConst[V any](value V) Const[V] {
  10. return Const[V]{
  11. value: value,
  12. }
  13. }
  14. // Getting the constant value from the
  15. // pointer so the struct must be in the memory already. (initialized as variable)
  16. func (c *Const[V]) Get() V {
  17. return c.value
  18. }