You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.
Type inference works, if I have a value to pass to the generic's construction, but that doesn't always make sense if I want to create an empty container, then fill it later.
struct Array<Contained> {
width: i64
height: i64
contents: raw[Contained]
fun create_array(width_: i64, height_: i64) -> Array {
mut array = new Array(width: width_, height: height_, contents: raw[])
let size = width_ * height_
unsafe { resize array.contents size }
return array
}
}
// works
let data = new Array(2,3,raw[false])
// does not work
// let data = Array<bool>::create_array(10, 12)
The text was updated successfully, but these errors were encountered:
I'm now unable to compile this example and feeling very confused. I was certain it was working a moment ago
lefticus
changed the title
Unable to explicitly create an instantiation of a generic struct
Unable to explicitly create an instantiation of a generic struct / create generic struct with array
Mar 9, 2024
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Type inference works, if I have a value to pass to the generic's construction, but that doesn't always make sense if I want to create an empty container, then fill it later.
The text was updated successfully, but these errors were encountered: