v icon indicating copy to clipboard operation
v copied to clipboard

map and Set does not support arbitrary keys

Open prashanth-hegde opened this issue 3 years ago • 1 comments

map currently only supports basic types (int, string, ...) as keys. A custom struct is not supported as keys. Example:

struct PersonalInfo {
  name string
  age int
}

mut info_map := map[PersonalInfo]int{}

gives this error

cgen error: map key type not supported

Set<T> also uses map behind the scenes and is indirectly affected.

prashanth-hegde avatar Sep 02 '22 13:09 prashanth-hegde

see discussion https://github.com/vlang/v/discussions/11927

depperm avatar Sep 11 '22 13:09 depperm