설명을 좀 하자면 Big 안에 Small이 포함되고, BigOption 안에 SmallOption이 포함되는 구조인데
Big::new에서 Small::new 할때 BigOption.small_option 떼줘서 small 만든담에 Big에 option이랑 small 넣으려하니까 레퍼런스가 꼬임

컴파일하면 아래처럼 나온다..

왜 안되는지는 알겠는데 어떻게 고쳐야할지 모르겠어

라이프타임은 다 동일한거라 clone하기도 애매하고 방법이 있을거같은데

Small에서 Deref 말고 다른 스마트 포인터(Ref같은거) 받은담에 레퍼런스 복사하는게 맞나?

어케하는게 젤 idiomatic한지 고수님들 힌트좀


error[E0515]: cannot return value referencing local data `option.small_option`
  --> test-bigsmall.rs:32:9
   |
31 |         let small = Small::new(&option.small_option);
   |                                -------------------- `option.small_option` is borrowed here
32 |         Self { option, small }
   |         ^^^^^^^^^^^^^^^^^^^^^^ returns a value referencing data owned by the current function

error[E0505]: cannot move out of `option` because it is borrowed
  --> test-bigsmall.rs:32:16
   |
29 | impl<'a> Big<'a> {
   |      -- lifetime `'a` defined here
30 |     fn new(option: BigOption) -> Self {
31 |         let small = Small::new(&option.small_option);
   |                                -------------------- borrow of `option.small_option` occurs here
32 |         Self { option, small }
   |         -------^^^^^^---------
   |         |      |
   |         |      move out of `option` occurs here
   |         returning this value requires that `option.small_option` is borrowed for `'a`

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0505, E0515.
For more information about an error, try `rustc --explain E0505`.