LINUX.ORG.RU

История изменений

Исправление KivApple, (текущая версия) :

Чтобы проверить, что не статик, добавил в A данные:

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&am...

И...

   Compiling playground v0.0.1 (/playground)
error[E0716]: temporary value dropped while borrowed
  --> src/main.rs:28:25
   |
26 | impl<'a> C<'a> {
   |      -- lifetime `'a` defined here
27 |     fn new(param: i32) -> Self {
28 |         let a: &'a A = &A { param };
   |                -----    ^^^^^^^^^^^ creates a temporary value which is freed while still in use
   |                |
   |                type annotation requires that borrow lasts for `'a`
...
34 |     }
   |     - temporary value is freed at the end of this statement

For more information about this error, try `rustc --explain E0716`.
error: could not compile `playground` (bin "playground") due to previous error

Исходная версия KivApple, :

Чтобы проверить, что не статик, добавил в A данные:

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&am...

И...

   Compiling playground v0.0.1 (/playground)
error[E0716]: temporary value dropped while borrowed
  --> src/main.rs:28:25
   |
26 | impl<'a> C<'a> {
   |      -- lifetime `'a` defined here
27 |     fn new(param: i32) -> Self {
28 |         let a: &'a A = &A { param };
   |                -----    ^^^^^^^^^^^ creates a temporary value which is freed while still in use
   |                |
   |                type annotation requires that borrow lasts for `'a`
...
34 |     }
   |     - temporary value is freed at the end of this statement

For more information about this error, try `rustc --explain E0716`.
error: could not compile `playground` (bin "playground") due to previous error