mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-05 03:17:50 +08:00
eval: Introduce a MapLike interface.
This commit is contained in:
parent
50af039e16
commit
65a0ab4e83
|
@ -10,6 +10,11 @@ type Map struct {
|
||||||
inner *map[Value]Value
|
inner *map[Value]Value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type MapLike interface {
|
||||||
|
Lener
|
||||||
|
IndexOneer
|
||||||
|
}
|
||||||
|
|
||||||
// NewMap creates a new Map.
|
// NewMap creates a new Map.
|
||||||
func NewMap(inner map[Value]Value) Map {
|
func NewMap(inner map[Value]Value) Map {
|
||||||
return Map{&inner}
|
return Map{&inner}
|
||||||
|
|
|
@ -17,6 +17,11 @@ type Struct struct {
|
||||||
Fields []Variable
|
Fields []Variable
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ Value = (*Struct)(nil)
|
||||||
|
_ MapLike = (*Struct)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
func (*Struct) Kind() string {
|
func (*Struct) Kind() string {
|
||||||
return "map"
|
return "map"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user