New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Range branch with label(break/continue/goto/return) #511
Conversation
JessonChan
commented
Jul 31, 2020
Codecov Report
@@ Coverage Diff @@
## master #511 +/- ##
==========================================
+ Coverage 89.90% 89.93% +0.03%
==========================================
Files 40 41 +1
Lines 10210 10295 +85
==========================================
+ Hits 9179 9259 +80
- Misses 752 754 +2
- Partials 279 282 +3
Continue to review full report at Codecov.
|
It seems too complex to implement this feature. |
Glad to discuss this. |
none-out/multi-out/break/continue/go on
In func TraitContainer(containerTy reflect.Type) ContainerTrait
type ContainerTrait struct {
Key, Value reflect.Type // Key can be nil, and it means the Iterator only has Value(), not has Key()
Iter interface{} // func(c interface{}) Iterator or func(c interface{}) ValueIterator
}
type Iterator interface {
Next() bool
Key() interface{}
Value() interface{}
}
type ValueIterator interface {
Next() bool
Key() reflect.Value
Value() reflect.Value
} And then for k, v = range container {
...
} can become: trait := TraitContainer(reflect.TypeOf(container))
for __iter := trait.Iter(container); __iter.Next(); {
k, v = __iter.Key().(trait.Key), __iter.Value().(trait.Value)
...
} |
这个转化很巧妙,没看到这个帖子之前,光看代码一脸懵逼 |