From C# v.7.0

New Features in C# 7.0:

This is a Rust translation of a C#7 feature:

fn foo() -> (x: u32, y: u32) {
    (10, 20)
}
fn main() {
    let p = foo();
    println!("{} {}", p.x, p.y);
    let (a, b) = foo();
}

That equals to:

struct Pair { x: u32, y: u32 }
fn foo() -> Pair {
    Pair { x: 10, y: 20 }
}
fn main() {
    let p = foo();
    println!("{} {}", p.x, p.y);
}
1 Like

This is anonymous structs: Pre-RFC: anonymous struct and union types

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.