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

RFC: Functional struct update for structs of different types but coinciding field names/types #7143

Closed
bblum opened this issue Jun 15, 2013 · 3 comments
Labels
A-grammar Area: The grammar of Rust A-type-system Area: Type system

Comments

@bblum
Copy link
Contributor

bblum commented Jun 15, 2013

I just thought of this and am not sure if there's some practical obstacle to it. Let's say you have:

struct Foo { a: T1, b: T2, c: T3 }
struct Bar { a: T2, b: T2 }

It would be nice to be able to write:

let bar: Bar = ...;
let foo: Foo = { c: type_3_value, ..bar };
@emberian
Copy link
Member

emberian commented Aug 1, 2013

I agree that this would be useful.

@huonw
Copy link
Member

huonw commented Dec 19, 2013

Triage: no change.

I'm personally ambivalent on this, but it might have some neat uses. FWIW, GHC is growing something tangentially related, "overloaded record fields", the core part of which is (in pseudo-Rust terms) essentially trait(s) HasField that give T: HasField<"foo", int> + HasField<"bar", f32> for

struct T {
    foo: int,
    bar: f32
}

so FSU would essentially become normal matching against HasField<"foo", T> for the fields foo: T that aren't explicitly listed. (This can't currently work directly for Rust, since we don't have strings in the type system.)

@emberian
Copy link
Member

I'm going to close this, due to the new RFC process.

flip1995 pushed a commit to flip1995/rust that referenced this issue Jun 30, 2022
add [`manual_find`] lint for function return case

part of the implementation discussed in rust-lang#7143

changelog: add [`manual_find`] lint for function return case
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-grammar Area: The grammar of Rust A-type-system Area: Type system
Projects
None yet
Development

No branches or pull requests

3 participants