Skip to content

Type of captured variable #4

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

Open
nrc opened this issue Jul 14, 2021 · 0 comments
Open

Type of captured variable #4

nrc opened this issue Jul 14, 2021 · 0 comments

Comments

@nrc
Copy link
Member

nrc commented Jul 14, 2021

Previous discussion, Zulip

E.g., if matching a String with a @ "foo", should a have type String, &str, or &String?

One 'nice to have' is for a (an unconstrained variable) and a @ ... to have the same type.

Note that &String can always be coerced to &str, so in most contexts is strictly more general. I think that if we follow the 'match ergonomics' binding mode rules, then that decides if the variable should be used by move or ref (i.e., if a should have type String or &String or &mut String). Note that if we're matching Ptr<String> then we can only bind by move if Ptr: DerefMove, since DerefMove does not yet exist, this is a type error unless Ptr is Box.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant