diff --git a/collections.go b/collections.go index 319e01a..108b58f 100644 --- a/collections.go +++ b/collections.go @@ -13,7 +13,7 @@ func ID[V any](v V) V { return v } -// SliceOf creates a []E generator. SliceOf(elem) is equivalent to SliceOfN(elem, -1, -1). +// SliceOf is a shorthand for [SliceOfN](elem, -1, -1). func SliceOf[E any](elem *Generator[E]) *Generator[[]E] { return SliceOfN(elem, -1, -1) } @@ -31,9 +31,7 @@ func SliceOfN[E any](elem *Generator[E], minLen int, maxLen int) *Generator[[]E] }) } -// SliceOfDistinct creates a []E generator. Elements of each generated slice are distinct according to keyFn. -// [ID] helper can be used as keyFn to generate slices of distinct comparable elements. -// SliceOfDistinct(elem, keyFn) is equivalent to SliceOfNDistinct(elem, -1, -1, keyFn). +// SliceOfDistinct is a shorthand for [SliceOfNDistinct](elem, -1, -1, keyFn). func SliceOfDistinct[E any, K comparable](elem *Generator[E], keyFn func(E) K) *Generator[[]E] { return SliceOfNDistinct(elem, -1, -1, keyFn) } @@ -103,7 +101,7 @@ func (g *sliceGen[E, K]) value(t *T) []E { return sl } -// MapOf creates a map[K]V generator. MapOf(key, val) is equivalent to MapOfN(key, val, -1, -1). +// MapOf is a shorthand for [MapOfN](key, val, -1, -1). func MapOf[K comparable, V any](key *Generator[K], val *Generator[V]) *Generator[map[K]V] { return MapOfN(key, val, -1, -1) } @@ -122,8 +120,7 @@ func MapOfN[K comparable, V any](key *Generator[K], val *Generator[V], minLen in }) } -// MapOfValues creates a map[K]V generator, where keys are generated by applying keyFn to values. -// MapOfValues(val, keyFn) is equivalent to MapOfNValues(val, -1, -1, keyFn). +// MapOfValues is a shorthand for [MapOfNValues](val, -1, -1, keyFn). func MapOfValues[K comparable, V any](val *Generator[V], keyFn func(V) K) *Generator[map[K]V] { return MapOfNValues(val, -1, -1, keyFn) } diff --git a/combinators.go b/combinators.go index 2ab9880..b3b1808 100644 --- a/combinators.go +++ b/combinators.go @@ -140,7 +140,7 @@ func (g *mappedGen[U, V]) value(t *T) V { } // Just creates a generator which always produces the given value. -// Just(val) is equivalent to SampledFrom([]V{val}). +// Just(val) is a shorthand for [SampledFrom]([]V{val}). func Just[V any](val V) *Generator[V] { return SampledFrom([]V{val}) } diff --git a/strings.go b/strings.go index 102937a..7948e04 100644 --- a/strings.go +++ b/strings.go @@ -70,7 +70,7 @@ type compiledRegexp struct { re *regexp.Regexp } -// Rune creates a rune generator. +// Rune creates a rune generator. Rune is equivalent to [RuneFrom] with default set of runes and tables. func Rune() *Generator[rune] { return runesFrom(true, defaultRunes, defaultTables...) } @@ -139,24 +139,17 @@ func (g *runeGen) value(t *T) rune { return runes[genIndex(t.s, len(runes), true)] } -// String creates a UTF-8 string generator. String() is equivalent to StringOf(Rune()). +// String is a shorthand for [StringOf]([Rune]()). func String() *Generator[string] { return StringOf(anyRuneGen) } -// StringN creates a UTF-8 string generator. -// If minRunes >= 0, generated strings have minimum minRunes runes. -// If maxRunes >= 0, generated strings have maximum maxRunes runes. -// If maxLen >= 0, generates strings have maximum length of maxLen. -// StringN panics if maxRunes >= 0 and minRunes > maxRunes. -// StringN panics if maxLen >= 0 and maxLen < maxRunes. -// StringN(minRunes, maxRunes, maxLen) is equivalent to StringOfN(Rune(), minRunes, maxRunes, maxLen). +// StringN is a shorthand for [StringOfN]([Rune](), minRunes, maxRunes, maxLen). func StringN(minRunes int, maxRunes int, maxLen int) *Generator[string] { return StringOfN(anyRuneGen, minRunes, maxRunes, maxLen) } -// StringOf creates a UTF-8 string generator. -// StringOf(elem) is equivalent to StringOfN(elem, -1, -1, -1). +// StringOf is a shorthand for [StringOfN](elem, -1, -1, -1). func StringOf(elem *Generator[rune]) *Generator[string] { return StringOfN(elem, -1, -1, -1) }