-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support iter.Seq2 for *FieldValue (#625)
* Support iter.Seq2 for *FieldValue * Add go 1.23 to test matrix * Rename method name and fix test
- Loading branch information
Showing
3 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
//go:build go1.23 | ||
|
||
package cmds | ||
|
||
import "iter" | ||
|
||
func (c HmsetFieldValue) FieldValueIter(seq iter.Seq2[string, string]) HmsetFieldValue { | ||
for field, value := range seq { | ||
c.cs.s = append(c.cs.s, field, value) | ||
} | ||
return c | ||
} | ||
|
||
func (c HsetFieldValue) FieldValueIter(seq iter.Seq2[string, string]) HsetFieldValue { | ||
for field, value := range seq { | ||
c.cs.s = append(c.cs.s, field, value) | ||
} | ||
return c | ||
} | ||
|
||
func (c XaddFieldValue) FieldValueIter(seq iter.Seq2[string, string]) XaddFieldValue { | ||
for field, value := range seq { | ||
c.cs.s = append(c.cs.s, field, value) | ||
} | ||
return c | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
//go:build go1.23 | ||
|
||
package cmds | ||
|
||
import ( | ||
"maps" | ||
"testing" | ||
) | ||
|
||
func iter0(s Builder) { | ||
s.Hmset().Key("1").FieldValue().FieldValueIter(maps.All(map[string]string{"1": "1"})).Build() | ||
s.Hset().Key("1").FieldValue().FieldValueIter(maps.All(map[string]string{"1": "1"})).Build() | ||
s.Xadd().Key("1").Id("*").FieldValue().FieldValueIter(maps.All(map[string]string{"1": "1"})).Build() | ||
} | ||
|
||
func TestIter(t *testing.T) { | ||
var s = NewBuilder(InitSlot) | ||
t.Run("0", func(t *testing.T) { iter0(s) }) | ||
} |