0
Follow
2
View

Why does borrowing this temporary value work? [duplicate]

daisho0906 注册会员
2023-01-26 10:32

If you bind a reference to a temporary, Rust extends the lifetime of the temporary as needed for the binding; see this answer for details.

See this comment. The extended lifetime of the temporary matches the lifetime of x in your example. When a struct containing references has no Drop implementation,

About the Author

Question Info

Publish Time
2023-01-26 10:32
Update Time
2023-01-26 10:32