pub struct BuildDiagnostics { /* private fields */ }Expand description
Sorted, deduplicated collection of BuildDiagnostics.
排序去重后的 BuildDiagnostic 集合。
Implementations§
Source§impl BuildDiagnostics
impl BuildDiagnostics
Sourcepub fn push(&mut self, diagnostic: BuildDiagnostic)
pub fn push(&mut self, diagnostic: BuildDiagnostic)
Append one diagnostic; duplicates are kept here and collapsed only by
BuildDiagnostics::iter, len, and render.
追加一条诊断;重复项在此保留,仅由 BuildDiagnostics::iter、len 与 render
折叠。
Sourcepub fn extend(&mut self, other: BuildDiagnostics)
pub fn extend(&mut self, other: BuildDiagnostics)
Move every diagnostic of other into this collection.
把 other 的全部诊断移入本集合。
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Whether nothing has been collected; true exactly when len is 0.
是否尚未收集到任何诊断;当且仅当 len 为 0 时为真。
Sourcepub fn iter(&self) -> impl Iterator<Item = &BuildDiagnostic>
pub fn iter(&self) -> impl Iterator<Item = &BuildDiagnostic>
Iterate the diagnostics in the exact order BuildDiagnostics::render
prints them, with byte-identical duplicates collapsed.
按 BuildDiagnostics::render 打印它们的完全相同顺序迭代诊断,并折叠完全相同的
重复项。
The read surface and the human renderer must agree: a CI job that counts
iter() items while a developer reads render() has to see the same
set, or the two disagree about whether “the build is clean”. Sorting and
deduplicating here (rather than once per caller) is what keeps them from
drifting; render itself is written in terms of this iterator.
读取面与人类可读渲染必须一致:CI 数 iter() 的条目、开发者读 render(),
两者必须看到同一集合,否则会对“构建是否干净“给出不同答案。把排序与去重放在
这里(而不是每个调用方各做一遍)正是防止两者漂移的办法;render 本身就以
这个迭代器书写。
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
The number of distinct diagnostics BuildDiagnostics::render would
print.
BuildDiagnostics::render 会打印的去重后诊断条数。
Sourcepub fn render(&self) -> String
pub fn render(&self) -> String
Render all distinct diagnostics as one human-readable report, or the empty string when there are none. 把所有去重后的诊断渲染为一份人类可读报告;没有诊断时返回空字符串。
Sourcepub fn to_json(&self) -> String
pub fn to_json(&self) -> String
Serialize the diagnostics as one JSON document for a machine reader. 把诊断序列化为供机器读取的单个 JSON 文档。
Hand-rolled rather than serde_json: the kernel deliberately has no
serialization dependency (AGENTS.md rule 3 keeps the kernel pure, and
serde_json is a cli/mcp dependency only), and the shape is eleven
flat string/integer fields. Adding a derive to the kernel for that would
put a new public dependency on the crate every host links.
手写而不是用 serde_json:内核刻意不带序列化依赖(AGENTS.md 规则 3 要求内核
保持纯净,serde_json 只是 cli/mcp 的依赖),而形状只有十一个扁平字符串/
整数字段。为此在内核上加 derive,等于给每个宿主都会链接的 crate 加一个新公开
依赖。
Every key is always present, so a reader never has to distinguish “absent”
from “empty”; line is 0 when the diagnostic has no line. The order is
the same as BuildDiagnostics::iter, so the JSON and the rendered text
list the same diagnostics in the same order.
所有键始终存在,读取方无需区分“缺失“与“空“;诊断没有行号时 line 为 0。
顺序与 BuildDiagnostics::iter 相同,因此 JSON 与渲染文本列出的是同一批
诊断、同一顺序。
Trait Implementations§
Source§impl Clone for BuildDiagnostics
impl Clone for BuildDiagnostics
Source§fn clone(&self) -> BuildDiagnostics
fn clone(&self) -> BuildDiagnostics
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more