Skip to content

Guide: lifetimes error example compiles successfully #16117

Closed
@mprobinson

Description

@mprobinson

http://doc.rust-lang.org/guide-lifetimes.html#returning-references

struct Point {x: f64, y: f64}
fn get_x_sh(p: &Point) -> &f64 {
    &p.x // Error reported here
}

Thanks to lifetime elision this example now compiles successfully.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions