8// Value is a generic thread-safe wrapper for any value type.
10// For slices, use [Slice]. For maps, use [Map]. Pointers are not supported.
11type Value[T any] struct {
16// NewValue creates a new Value with the given initial value.
18// Panics if t is a pointer, slice, or map. Use the dedicated types for those.
19func NewValue[T any](t T) *Value[T] {
20 v := reflect.ValueOf(t)
23 panic("csync.Value does not support pointer types")
25 panic("csync.Value does not support slice types; use csync.Slice")
27 panic("csync.Value does not support map types; use csync.Map")
29 return &Value[T]{v: t}
32// Get returns the current value.
33func (v *Value[T]) Get() T {
39// Set updates the value.
40func (v *Value[T]) Set(t T) {
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list