- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我目前正在浏览 the Rust Documentation了解固有的实现。什么是“标称类型”?当他们说“与实现类型相关的项目”时,他们指的是什么?
在 C 或 C++ 中是否有与此相关的模拟?
最佳答案
嗯,那是语言引用。用它来学习 Rust 当然是可能的,但有点像尝试通过阅读字典来学习英语。你试过Rust Book了吗? ?
无论如何,正如第一段所述,“标称类型”是:
impl /* --> */ Point /* <-- this is the "nominal type" */ {
fn log(&self) { ... }
}
它是固有impl
主题的类型. “关联项目”是与标称类型关联的项目(如 fn
、const
或 type
)。
如果你有段落:
Let's talk about Raymond. His hair is brown. He knows how to dance.
这大致相当于:
struct Raymond; // introduce the Raymond type.
impl Raymond { // associate some items with Raymond.
const HAIR: Colour = Colour::Brown;
fn dance(&mut self) { ... }
}
fn main() {
let mut ray = Raymond;
println!("Raymond's hair is {}", Raymond::HAIR);
ray.dance();
}
(顺便说一句:段落中的代词(如“他”或“他”)将变为 self
或 Self
中的 impl
。)
impl
正在将这些项目与标称类型相关联。注意如何 HAIR
是 Raymond
的“内部”类型。您也可以将上面的代码写成:
struct Raymond;
const RAYMOND_HAIR: Colour = Colour::Brown;
fn raymond_dance(ray: &mut Raymond) { ... }
fn main() {
let mut ray = Raymond;
println!("Raymond's hair is {}", RAYMOND_HAIR);
raymond_dance(&mut ray);
}
这里没有固有的impl
s,所以 RAYMOND_HAIR
和 raymond_dance
项目与 Raymond
无关直接输入。除了方便之外,两者之间没有根本区别。
至于将其与 C++ 联系起来……这很棘手,因为 Rust 区分固有和非固有 impl
s 和 C++...不会。最接近的类比是说它们就像 struct
的一部分。主体不是字段,也不是重写基类中的方法。
关于rust - 在固有实现的上下文中, "nominal type"是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49277733/
我正在分析 V(net)=1327 和 E(net)=4121 的合着网络(net)。 我试图找到 assortativity.nominal(net, types=V(net)$field) 这是基
Weka 中是否有任何现有类可以将实例从名义型转换为具有以下输入和输出格式的二进制。 输入实例格式和数据 |Fruits|Test|Price| -------------------------
我目前正在浏览 the Rust Documentation了解固有的实现。什么是“标称类型”?当他们说“与实现类型相关的项目”时,他们指的是什么? 在 C 或 C++ 中是否有与此相关的模拟? 最佳
查看this table describing the data types in VB . 其中一列标有“Nominal storage allocation”。这是什么意思?为什么这里有“标称”这
查看this table describing the data types in VB . 其中一列标有“Nominal storage allocation”。这是什么意思?为什么这里有“标称”这
我有一个表格(指定),如下所示: Year Category Artist-Name Title Album 1980 AlbumOfYe
我的应用程序有一个 Widget 扩展,在我的扩展中定义了结构 MyStruct,目标成员为 MyAppWidgetExtension。我还有一个 UnitTesting 目标,我想在其中为我的主应用
我的代码工作(代码测试)使用闭包来添加我日历的点击事件 tu 项目。如果用户点击日期,代码会添加一行到表 ID myTable(数据表插件) $dowElement.addClass('event-c
我读自this article “Java 几乎完全是名义上的类型”。所以在 Java 中有结构类型的部分。 Java 类型系统的名义部分和结构部分是什么? 最佳答案 根据同一作者之前的帖子 - re
我在尝试扩展诸如 (Int, Int) 或 Any 之类的非正统“类型”时看到此错误: Non-nominal type 'Any' cannot be extended 那么什么使类型成为非标称类型
所以我试图理解通用协议(protocol)和类: protocol ListPresenterType where View.PDO.SW == Dispatcher.SW { associa
我正在尝试使用命令对具有 51 个特征的数据进行分类 DecisionTable -X 1 -S "weka.attributeSelection.GreedyStepwise -T -1.79 -N
我在我的 iOS 应用程序中使用 Realm,由于线程安全问题,我选择为我的数据模型创建一个领域层,以及一个可以与领域对象相互转换的层。 我实际做的事情要复杂得多,但我能够创建一个 playgroun
我编写了一个扩展程序,用于在 Collection 中搜索特定类型的对象。 extension Collection { /// Finds and returns the first ele
晚上好, 我正在从事监督分类任务。我有一个很大的 arff 文件,其中充满了格式为“text”、class 的数据。只有两个类(class),E 和 I。 我可以将这些数据加载到Weka Explor
我正在使用这个扩展来在 urlSession 回调中检索 HTTP header : extension HTTPURLResponse { func get(_ header: String
我正在尝试将 Objective-C 项目转换为 Swift,这是 Objective-C 中的 .h 文件之一: typedef void(^PrintBlock)(HLPrinter *print
我是一名优秀的程序员,十分优秀!