Skip to content

about the Impls of lifetimes example #75

@savageKarl

Description

@savageKarl

https://learning-rust.github.io/docs/lifetimes/#03-with-impls-and-traits

struct Struct<'a> {
    x: &'a str
}
    impl<'a> Struct<'a> {
        fn function<'a>(&self) -> &'a str {
            self.x
        }
    }

error[E0496]: lifetime name 'a shadows a lifetime name that is already in scope
--> src/lib.rs:5:21
|
4 | impl<'a> Struct<'a> {
| -- first declared here
5 | fn function<'a>(&self) -> &'a str {
| ^^ lifetime 'a already in scope

For more information about this error, try rustc --explain E0496.
error: could not compile playground (lib) due to 1 previous error

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions