Skip to content

Commit 24f65e3

Browse files
committed
Use 'shorthand' in docs consistently
1 parent 68a5376 commit 24f65e3

File tree

3 files changed

+9
-19
lines changed

3 files changed

+9
-19
lines changed

collections.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func ID[V any](v V) V {
1313
return v
1414
}
1515

16-
// SliceOf creates a []E generator. SliceOf(elem) is equivalent to SliceOfN(elem, -1, -1).
16+
// SliceOf is a shorthand for [SliceOfN](elem, -1, -1).
1717
func SliceOf[E any](elem *Generator[E]) *Generator[[]E] {
1818
return SliceOfN(elem, -1, -1)
1919
}
@@ -31,9 +31,7 @@ func SliceOfN[E any](elem *Generator[E], minLen int, maxLen int) *Generator[[]E]
3131
})
3232
}
3333

34-
// SliceOfDistinct creates a []E generator. Elements of each generated slice are distinct according to keyFn.
35-
// [ID] helper can be used as keyFn to generate slices of distinct comparable elements.
36-
// SliceOfDistinct(elem, keyFn) is equivalent to SliceOfNDistinct(elem, -1, -1, keyFn).
34+
// SliceOfDistinct is a shorthand for [SliceOfNDistinct](elem, -1, -1, keyFn).
3735
func SliceOfDistinct[E any, K comparable](elem *Generator[E], keyFn func(E) K) *Generator[[]E] {
3836
return SliceOfNDistinct(elem, -1, -1, keyFn)
3937
}
@@ -103,7 +101,7 @@ func (g *sliceGen[E, K]) value(t *T) []E {
103101
return sl
104102
}
105103

106-
// MapOf creates a map[K]V generator. MapOf(key, val) is equivalent to MapOfN(key, val, -1, -1).
104+
// MapOf is a shorthand for [MapOfN](key, val, -1, -1).
107105
func MapOf[K comparable, V any](key *Generator[K], val *Generator[V]) *Generator[map[K]V] {
108106
return MapOfN(key, val, -1, -1)
109107
}
@@ -122,8 +120,7 @@ func MapOfN[K comparable, V any](key *Generator[K], val *Generator[V], minLen in
122120
})
123121
}
124122

125-
// MapOfValues creates a map[K]V generator, where keys are generated by applying keyFn to values.
126-
// MapOfValues(val, keyFn) is equivalent to MapOfNValues(val, -1, -1, keyFn).
123+
// MapOfValues is a shorthand for [MapOfNValues](val, -1, -1, keyFn).
127124
func MapOfValues[K comparable, V any](val *Generator[V], keyFn func(V) K) *Generator[map[K]V] {
128125
return MapOfNValues(val, -1, -1, keyFn)
129126
}

combinators.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ func (g *mappedGen[U, V]) value(t *T) V {
140140
}
141141

142142
// Just creates a generator which always produces the given value.
143-
// Just(val) is equivalent to SampledFrom([]V{val}).
143+
// Just(val) is a shorthand for [SampledFrom]([]V{val}).
144144
func Just[V any](val V) *Generator[V] {
145145
return SampledFrom([]V{val})
146146
}

strings.go

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ type compiledRegexp struct {
7070
re *regexp.Regexp
7171
}
7272

73-
// Rune creates a rune generator.
73+
// Rune creates a rune generator. Rune is equivalent to [RuneFrom] with default set of runes and tables.
7474
func Rune() *Generator[rune] {
7575
return runesFrom(true, defaultRunes, defaultTables...)
7676
}
@@ -139,24 +139,17 @@ func (g *runeGen) value(t *T) rune {
139139
return runes[genIndex(t.s, len(runes), true)]
140140
}
141141

142-
// String creates a UTF-8 string generator. String() is equivalent to StringOf(Rune()).
142+
// String is a shorthand for [StringOf]([Rune]()).
143143
func String() *Generator[string] {
144144
return StringOf(anyRuneGen)
145145
}
146146

147-
// StringN creates a UTF-8 string generator.
148-
// If minRunes >= 0, generated strings have minimum minRunes runes.
149-
// If maxRunes >= 0, generated strings have maximum maxRunes runes.
150-
// If maxLen >= 0, generates strings have maximum length of maxLen.
151-
// StringN panics if maxRunes >= 0 and minRunes > maxRunes.
152-
// StringN panics if maxLen >= 0 and maxLen < maxRunes.
153-
// StringN(minRunes, maxRunes, maxLen) is equivalent to StringOfN(Rune(), minRunes, maxRunes, maxLen).
147+
// StringN is a shorthand for [StringOfN]([Rune](), minRunes, maxRunes, maxLen).
154148
func StringN(minRunes int, maxRunes int, maxLen int) *Generator[string] {
155149
return StringOfN(anyRuneGen, minRunes, maxRunes, maxLen)
156150
}
157151

158-
// StringOf creates a UTF-8 string generator.
159-
// StringOf(elem) is equivalent to StringOfN(elem, -1, -1, -1).
152+
// StringOf is a shorthand for [StringOfN](elem, -1, -1, -1).
160153
func StringOf(elem *Generator[rune]) *Generator[string] {
161154
return StringOfN(elem, -1, -1, -1)
162155
}

0 commit comments

Comments
 (0)