惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
J
Java Code Geeks
B
Blog
腾讯CDC
博客园 - 三生石上(FineUI控件)
S
SegmentFault 最新的问题
H
Hackread – Cybersecurity News, Data Breaches, AI and More
博客园 - Franky
罗磊的独立博客
月光博客
月光博客
Jina AI
Jina AI
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
D
Docker
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
G
Google Developers Blog
V
Visual Studio Blog
I
InfoQ
有赞技术团队
有赞技术团队
D
DataBreaches.Net
Microsoft Security Blog
Microsoft Security Blog
WordPress大学
WordPress大学
阮一峰的网络日志
阮一峰的网络日志
宝玉的分享
宝玉的分享
Blog — PlanetScale
Blog — PlanetScale

The Rust Programming Language Forum - Latest topics

Beginner building a Rust backend framework (AI-assisted) — feedback appreciated C++ to Rust -- Exceptions Re-exporting a trait with a custom derive_macro Gold linker is deprecated Why is using PhantomData valid in this case? Code review for Static Pool Allocator Looking for a pool based allocator Why is this legal? What does it mean for Rustc to run "out of TLS keys"? Using async/await internally with no internal runtime, but exposing a nonblocking poll API — is this a reasonable design? Testing functions that use randomness `cargo-path`: improve coding agents&#39; ability to find Rust documentation Rust task runners Lifetime weird case Windows - USB device not detected A random rustc-ice-[...].txt file appeared Develop rust where the environment is setup in a docker Undefined Behavior: in-bounds pointer arithmetic failed: attempting to offset pointer by 20 bytes, but got alloc238 which is only 1 byte from the end of the allocation Unbug 0.5 - Runtime debug assertions Is there a tiny error in section 6.2 Reference types? Lifetime woes implementing ratatui::Widget for a reference Rusqlite + Chrono: How do I simplify code to obtain chrono datetime value From OOP to Rust – struggling with code organization and data structure design Way to avoid a self-referential struct Rust RF and audio resources/communities Whyhttp - HTTP mocks that fail where the bug actually is Using tokio channel permits in a tower service Arc::increment_strong_count design question (cross-post) `&T`, `&mut T`, `Pin<&mut T>` and `&Cell<T>`: Ways of Borrowing a `T` Ratatui detect arrow key press and release
Confusion about struct variance with &mut dyn
foonathan · 2026-04-22 · via The Rust Programming Language Forum - Latest topics
Hello, I'm a bit confused by the following Rust error: Rust Playground trait Trait {} struct Impl; impl Trait for Impl {} struct Holder<'r> { r: &'r mut dyn Trait, } fn static_holder() -> Holder<'static> { Holder{ r: Box::leak(Box::new(Impl)) } } impl<'r> Default for Holder<'r> { fn default() -> Holder<'r> { static_holder() } } I'm getting: error: lifetime may not live long enough --> src/lib.rs:16:9 | 14 | impl<'r> Default for Holder<'r> { | -- lifetime `'r` defined here 15 | fn default() -> Holder<'r> { 16 | static_holder() | ^^^^^^^^^^^^^^^ returning this value requires that `'r` must outlive `'static` | = note: requirement occurs because of the type `Holder<'_>`, which makes the generic argument `'_` invariant = note: the struct `Holder<'r>` is invariant over the parameter `'r` = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance Why is Holder<'r> invariant over r ? The linked nomicon says &'r mut T is covariant over 'r . Why does it work when I remove the dyn Trait and instead hardcode Impl ? Rust Playground Why does it work when I manually deconstruct static_holder and reconstruct a new Holder instance? Rust Playground Thanks! Jonathan 4 posts - 3 participants Read full topic