sophiajt / june

MIT License
813 stars 31 forks source link

Generic methods #59

Closed sophiajt closed 2 months ago

sophiajt commented 2 months ago

This adds the ability to have a method on a generic type.

For example:

struct Foo<T> {
    x: T

    fun get_value(self) [return == self] -> T  {
        return self.x
    }
}

fun main() {
    let bar = new Foo(x: 100)

    println(bar.get_value())
}

You'll notice that the lifetime checker is strict about the lifetime requirements of T, as it can be any type, including pointers.