Skip to content

Is it possible to cast generic types to Data? #547

Closed Answered by KtorZ
eddiemundo asked this question in Q&A
Discussion options

You must be logged in to vote

It is indeed not possible to cast a non-specialised generic type (e.g. T<a>) to Data. You can only cast types that have a concrete representation. In your example, however, T<Int> is very much concrete, so this would work:

fn t_to_data(t: T<Int>) -> Datum {
  InlineDatum(t.a)
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by rvcas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants