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 passing by non-copying value #1109

Merged
merged 3 commits into from Jun 17, 2018
Merged

Conversation

andrewrk
Copy link
Member

@andrewrk andrewrk commented Jun 14, 2018

closes #733

Here's the new thing you're allowed to do:

test "pass by non-copying value" {
    assert(bar(Point{ .x = 1, .y = 2 }) == 3);
}

const Point = struct {
    x: i32,
    y: i32,
};

fn bar(pt: Point) i32 {
    return pt.x + pt.y;
} 

See #733 (comment)

All the old code still works, but it is now un-idiomatic when one would be better using these semantics.

And then the breaking change will come when we remove the implicit cast from T to *const T.

@andrewrk andrewrk force-pushed the pass-by-non-copying-value branch 2 times, most recently from 87b27a9 to 66f5f77 Compare June 14, 2018 03:18
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

Successfully merging this pull request may close these issues.

add another way of passing non-copyable things as parameters
2 participants