1
1
package jsonvalue
2
2
3
+ // MARK: v.MustSet(xxx).At(xxx)
4
+
3
5
// MustSetter is just like Setter, but not returning sub-value or error.
4
6
type MustSetter interface {
5
7
// At completes the following operation of Set(). It defines position of value
@@ -25,7 +27,7 @@ type mSetter struct {
25
27
// MustSet is just like Set, but not returning sub-value or error.
26
28
func (v * V ) MustSet (child any ) MustSetter {
27
29
setter := v .Set (child )
28
- return & mSetter {
30
+ return mSetter {
29
31
setter : setter ,
30
32
}
31
33
}
@@ -129,6 +131,32 @@ func (v *V) MustSetArray() MustSetter {
129
131
return v .MustSet (NewArray ())
130
132
}
131
133
132
- func (s * mSetter ) At (firstParam any , otherParams ... any ) {
134
+ func (s mSetter ) At (firstParam any , otherParams ... any ) {
133
135
_ , _ = s .setter .At (firstParam , otherParams ... )
134
136
}
137
+
138
+ // MARK: v.At(xxx).Set(xxx)
139
+
140
+ // AtSetter works like v.MustSet(...).At(...), just with different sequence.
141
+ type AtSetter interface {
142
+ Set (subValue any )
143
+ }
144
+
145
+ // At works like v.MustSet(...).At(...), just with different sequence.
146
+ func (v * V ) At (firstParam any , otherParams ... any ) AtSetter {
147
+ return atSetter {
148
+ v : v ,
149
+ firstParam : firstParam ,
150
+ otherParams : otherParams ,
151
+ }
152
+ }
153
+
154
+ type atSetter struct {
155
+ v * V
156
+ firstParam any
157
+ otherParams []any
158
+ }
159
+
160
+ func (a atSetter ) Set (sub any ) {
161
+ a .v .MustSet (sub ).At (a .firstParam , a .otherParams ... )
162
+ }
0 commit comments