macro_rules! external_object {
{ @tokens collector: $collector:ident, $($tokens:tt)* } => { ... };
{ @tokens $($tokens:tt)* } => { ... };
{ $($tokens:tt)* } => { ... };
}Expand description
kind is the handle-marker type this file declares (pub struct <Kind>;), so
write that type first and reference it here: an editor cannot complete a name
the author has not written yet, and kind is captured as an identifier
rather than an expression, which is also why value completion does not fire
there. Every other field completes normally.
kind 就是本文件声明的那个 handle 标记类型(pub struct <Kind>;):先写出该类型,
再在这里引用它。编辑器无法补全一个作者还没写下的名字,而且 kind 是以标识符而非
表达式捕获的——这也是它的值位不会弹候选的原因。其余字段的值都能正常补全。
Declare a registration face: kind is the only required field; every other
field is optional and defaults the way the generated compact form defaults
them — source to this file, preset/parts to NoPreset/NoParts,
handle and params to kind, name to the kind’s spelling, summary to
empty, exports/requires/provides/runtime_checks to empty,
needs_registry to false, registry_name to the module’s last segment,
parent to the package’s root, getting_from_other_registry to None,
registry_rule_path to this file, and registry_rule to
RegistrationRule::ANY (see the comment in the expansion).
声明一个注册面:只有 kind 必填,其余字段都可省略,并按生成的紧凑形式取默认值——
source 取本文件、preset/parts 取 NoPreset/NoParts、handle 取 kind、
handle/params 取 kind、name 取 kind 的拼写、summary 取空、exports/requires/provides/
runtime_checks 取空、needs_registry 取 false、registry_name 取模块名末段、
parent 取包根、getting_from_other_registry 取 None、registry_rule_path 取
本文件、registry_rule 取 RegistrationRule::ANY(原因见展开处的注释)。
Declare a registration face owned by an external crate.
声明由外部 crate 所有的注册面。
Unlike generated parent-specific macros, this form receives its source path explicitly; an external crate is not part of the host’s generated tree. 与生成的父级专属宏不同,此形式显式接收源码路径;外部 crate 不在宿主 自动生成的模块树中。
An external face is written with braces like every other face, so the editor is told to insert them. 外部注册面与其它注册面一样用花括号书写,因此这里告诉编辑器插入花括号。