0

I have a generic Pair struct:

struct Pair<T> {
    name: String,
    value: T,
}

Is it possible to define an struct to have a list of Pair with different <T>:

struct MyList {
   elements:
   #a list of Pair<T> with different T
}

So we can use this:

let onelement : Pair<String> = Pair {name: String::from("title"), value: String::from("My awesome title"),};
let anotherelement: Pair<u128> = Pair {name: String::from("completion"), value: 10,};
let s = MyList::new();
s.append(oneelement);
s.append(anotherlement)
somenxavier
  • 963
  • 2
  • 10
  • 35

0 Answers0