Skip to main content

BuildDiagnostics

Struct BuildDiagnostics 

Source
pub struct BuildDiagnostics { /* private fields */ }
Expand description

Sorted, deduplicated collection of BuildDiagnostics. 排序去重后的 BuildDiagnostic 集合。

Implementations§

Source§

impl BuildDiagnostics

Source

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 折叠。

Source

pub fn extend(&mut self, other: BuildDiagnostics)

Move every diagnostic of other into this collection. 把 other 的全部诊断移入本集合。

Source

pub fn is_empty(&self) -> bool

Whether nothing has been collected; true exactly when len is 0. 是否尚未收集到任何诊断;当且仅当 len 为 0 时为真。

Source

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 本身就以 这个迭代器书写。

Source

pub fn len(&self) -> usize

The number of distinct diagnostics BuildDiagnostics::render would print. BuildDiagnostics::render 会打印的去重后诊断条数。

Source

pub fn render(&self) -> String

Render all distinct diagnostics as one human-readable report, or the empty string when there are none. 把所有去重后的诊断渲染为一份人类可读报告;没有诊断时返回空字符串。

Source

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

Source§

fn clone(&self) -> BuildDiagnostics

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BuildDiagnostics

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for BuildDiagnostics

Source§

fn default() -> BuildDiagnostics

Returns the “default value” for a type. Read more
Source§

impl Eq for BuildDiagnostics

Source§

impl PartialEq for BuildDiagnostics

Source§

fn eq(&self, other: &BuildDiagnostics) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for BuildDiagnostics

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.