Struct std::ptr::DynMetadata[−][src]

pub struct DynMetadata<Dyn> where
    Dyn: ?Sized, 
{ /* fields omitted */ }
🔬 This is a nightly-only experimental API. (ptr_metadata #81513)
Expand description

Dyn = dyn SomeTrait trait 对象类型的元数据。

它是指向 vtable (虚拟调用表) 的指针,该表表示操作存储在 trait 对象内部的具体类型所需的所有信息。 该 vtable 尤其包含:

  • 类型大小
  • 类型对齐
  • 指向该类型的 drop_in_place impl 的指针 (对于纯旧数据,它可能是 no-op)
  • 指向 trait 类型实现的所有方法的指针

请注意,前三个是特殊的,因为它们是分配,丢弃和释放任何 trait 对象所必需的。

可以使用不是 dyn trait 对象 (例如 DynMetadata<u64>) 的类型参数来命名此结构体,但不能获得该结构体的有意义的值。

Implementations

🔬 This is a nightly-only experimental API. (ptr_metadata #81513)

返回与此 vtable 关联的类型的大小。

🔬 This is a nightly-only experimental API. (ptr_metadata #81513)

返回与此 vtable 关联的类型的对齐方式。

🔬 This is a nightly-only experimental API. (ptr_metadata #81513)

将大小和对齐方式一起返回为 Layout

Trait Implementations

返回值的副本。 Read more

从 source 执行复制分配。 Read more

使用给定的格式化程序格式化该值。 Read more

将该值输入给定的 Hasher。 Read more

将这种类型的切片送入给定的 Hasher 中。 Read more

此方法返回 self 和 other 之间的 Ordering。 Read more

比较并返回两个值中的最大值。 Read more

比较并返回两个值中的最小值。 Read more

将值限制为一定的时间间隔。 Read more

此方法测试 self 和 other 值是否相等,并由 == 使用。 Read more

此方法测试 !=。

如果存在,则此方法返回 self 和 other 值之间的顺序。 Read more

此方法测试的内容少于 (对于 self 和 other),并且由 < 操作员使用。 Read more

此方法测试小于或等于 (对于 self 和 other),并且由 <= 运算符使用。 Read more

此方法测试大于 (对于 self 和 other),并且由 > 操作员使用。 Read more

此方法测试是否大于或等于 (对于 self 和 other),并且由 >= 运算符使用。 Read more

Auto Trait Implementations

Blanket Implementations

获取 self 的 TypeId。 Read more

从拥有的值中一成不变地借用。 Read more

从拥有的值中借用。 Read more

执行转换。

执行转换。

获得所有权后的结果类型。

通常通过克隆从借用数据中创建拥有的数据。 Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into #41263)

recently added

使用借来的数据来替换拥有的数据,通常是通过克隆。 Read more

发生转换错误时返回的类型。

执行转换。

发生转换错误时返回的类型。

执行转换。