shanliu 发表于 2022-04-27 17:18
struct Ba<'t>{ str:String, a:&'t str, } fn aaa()->Ba<'t>{ let b=format!("xxxx"); Ba{ str:b, a:b.as_str() } }
如何返回自引用的变量 以上代码中,b 应该不会被释放,
unsafe + Pin
目前基本上不要想安全的自引用了,存在 move 的引用失效问题
评论区
写评论unsafe + Pin
目前基本上不要想安全的自引用了,存在 move 的引用失效问题