以下代码段来自path.rs的锈源代码
impl AsRef<Path> for String { fn as_ref(&self) -> &Path { Path::new(self) } }
它似乎Path从堆栈帧返回新创建的对象的引用.它如何绕过Rust的借用检查规则?堆栈对象应仅具有当前帧的生存期,并且临时对象的返回引用应产生错误.
Path
syntax lifetime rust borrow-checker borrowing
borrow-checker ×1
borrowing ×1
lifetime ×1
rust ×1
syntax ×1