Why is using PhantomData valid in this case?
monok-robeto
·
2026-04-24
·
via The Rust Programming Language Forum - Latest topics
Hi everyone, I'm new to Rust, but I don't understand why PhantomData helps the following code compile. However, when I directly impl F, even though I've already set a constraint for P, it doesn't compile successfully? //impl<F, P> TSystem for F // ❌ ERROR impl<F, P> TSystem for PhantomSystem<F, P> // ✅ OK !? where F: Fn(P), P: TSystemParam + 'static, { fn run(self) { (self.0)(P::new()); } //fn run(self) { (self)(P::new()); } } 1 post - 1 participant Read full topic
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。