具体例が無いのも何なので一応

RustとC++コード例 >>113での要点はfooの中身
https://ideone.com/jo5Ymj
https://ideone.com/JIAr9h