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

推荐订阅源

Blog — PlanetScale
Blog — PlanetScale
Y
Y Combinator Blog
G
Google Developers Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
L
LangChain Blog
S
SegmentFault 最新的问题
J
Java Code Geeks
V
Visual Studio Blog
H
Help Net Security
Stack Overflow Blog
Stack Overflow Blog
aimingoo的专栏
aimingoo的专栏
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
Tailwind CSS Blog
Microsoft Azure Blog
Microsoft Azure Blog
博客园_首页
H
Hackread – Cybersecurity News, Data Breaches, AI and More
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - Franky
B
Blog RSS Feed
The Cloudflare Blog
MyScale Blog
MyScale Blog
月光博客
月光博客
Microsoft Security Blog
Microsoft Security Blog
美团技术团队

The Rust Programming Language Forum - Latest posts

What's everyone working on this week (21/2026)? Rust Function Call with one Param Iced + Canvas + Text: How do I create a style for canvas text "Value dropped while borrowed" as a lifetime mismatch Weird `use of moved value` behaviour Slightly surprising behavior of a while loop Clap: how to disable options after a certain positional argument How do i tell rust-analyzer what kind of bracket to use for a macro? Iterator + Borrow Checker: Work around borrowing already borrowed mutable variable Requesting data via mavlink SKILLS.md for Rust development 🧵 Stringlet UTF-8 Hack Option Niche? Iterator + Map - How do divide every element, including the last element, by the last element Why can't we store returned value of a function in a variable if one of the parameters goes out of scope My first crate :D, floop: A more convenient and less error prone replacement for loop `{ select! { .. }}` Sorting is slow because architectures are wrong — zan-sort redesigns the architecture, not the algorithm Iced Font - Create a custom monospace font to display dollar amounts Is the UnsafePinned RFC wrong about being able to return `&mut T` from `get_mut_unchecked`? Fixing Polars 0.37 compilation errors: Hashbrown 0.17 dependency conflict and decimal parsing Any plans for improving error diagnostic in Rust 2.0? How do I build completely offline? Is `&mut T -> &mut ManuallyDrop<T>` well-defined and sound? Would you use this? — fixtura, declarative fake data injection for tests Foreign trait restrictions on native types make generics hard to use Cargo Exclude Directive Compiler reasoning around a modulo counter Multiple mutable references to elements within one vector Handling non-`Send` data in a `Send` closure Review: Static Multi Pool Allocator Rmquickjs - High-level MicroQuickJS bindings for Rust
Confusion about struct variance with &mut dyn
foonathan · 2026-04-22 · via The Rust Programming Language Forum - Latest posts
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