benbjohnson / benbjohnson/immutable

Allow Creating Immutable Builders (Map/SortedSet/List) intialised with initial Values

Open
#45 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
745
Forks
37
PR merge metrics
No merged PRs in 30d

Description

Right now, `ListBuilder, MapBuilder and SortedSetBuilder) are intialised with empty data structures. This is great if you want to create an object from scratch, but doesn't cover the use case where you have an existing object and want to make a large number of modifications to it.

I propose we add functions that allow a user to create builders from initial data structures. For example:
```
NewSortedSetBuilderFromExisting[T any](s SortedSet[T]) *SortedSetBuilder[T]
```
We would guarantee that the builder itself would mutate a copy so that the initial data structure would remain immutable.

Happy to make a PR if you think this would be useful.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.