无法为包含PhantomData的类型提出需要调试的类型特征

时间:2016-10-17 22:46:50

标签: rust typetraits

给出以下代码(Rust Playground):

use std::fmt::Debug;
use std::marker::PhantomData;

trait Herp: Debug {}

#[derive(Debug)]
struct Derp<S: ?Sized> {
    phantom: PhantomData<S>
}

impl<S: ?Sized> Herp for Derp<S> {}

发生以下错误:

error[E0277]: the trait bound `S: std::fmt::Debug` is not satisfied
  --> src/...
   |
37 | impl<S: ?Sized> Herp for Derp<S> {}
   |                 ^^^^
   |
   = help: consider adding a `where S: std::fmt::Debug` bound
   = note: required because of the requirements on the impl of `std::fmt::Debug` for `Derp<S>`
   = note: required by `Herp

我觉得这种行为不合适,因为DebugDerp正确派生而PhantomData<T>应该Debug实施T,而不管Router.map(function() { this.route('colleges'); this.route('departments'); this.route('faculty'); }); application app routes colleges.js departments.js faculty.js )。我在搜索中也找不到任何可能导致此错误的内容。

为什么我不能为包含幻像的类型实现需要Debug的特性?

0 个答案:

没有答案