immutable

package
v0.21.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 5, 2025 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

The immutable package defines immutable wrappers around common data structures. These are used for additional type safety inside gopls.

See the "persistent" package for copy-on-write data structures.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Map

type Map[K comparable, V any] struct {
	// contains filtered or unexported fields
}

Map is an immutable wrapper around an ordinary Go map.

func MapOf

func MapOf[K comparable, V any](m map[K]V) Map[K, V]

MapOf wraps the given Go map.

The caller must not subsequently mutate the map.

func (Map[K, V]) All added in v0.20.0

func (m Map[K, V]) All() iter.Seq2[K, V]

All returns an iterator over each mapped (key, value) pair.

func (Map[K, V]) Len

func (m Map[K, V]) Len() int

Len returns the number of entries in the Map.

func (Map[K, V]) Value

func (m Map[K, V]) Value(k K) (V, bool)

Value returns the mapped value for k. It is equivalent to the commaok form of an ordinary go map, and returns (zero, false) if the key is not present.