1

Like this:

    struct S<'a> {
        content : String,
        reference : Option<&'a String>

    }

    impl <'a> S<'a> {
        fn new(content: String) -> S<'a> {
            let mut s = S {
                content,
                reference : None
            };
            s.reference.replace(&s.content);
            s
        }
    }

Where reference stored a reference of its content.

If it's impossible, why?

And is there anything works similar to it?

Riton Elion
  • 103
  • 5

0 Answers0