Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for implementations on generic structs #1

Closed
jamesgarfield opened this issue Dec 19, 2014 · 0 comments
Closed

Allow for implementations on generic structs #1

jamesgarfield opened this issue Dec 19, 2014 · 0 comments

Comments

@jamesgarfield
Copy link
Contributor

Allow for pattern matching on struct types.

From a generic specification of

type T struct {
    done chan struct{}
}

func (t T) Terminate() {
    t.done <- struct{}{}
}

be able to pattern match onto structurally similar, but extended structs, e.g.

type IntStep {
    In   chan <- int
    Out  <- chan int
    done chan struct{}
}

This naturally leads to generic specifications on empty structs being applicable to all structs.

Possible application

type T struct{}
func (t T) Json() string {
   //generic json encoding code
}
jamesgarfield added a commit that referenced this issue Mar 27, 2015
Update "astutil" import path.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant