pub struct Explain {
pub code: &'static str,
pub blurb: &'static str,
pub example: &'static str,
pub page: &'static str,
pub anchor: &'static str,
}Expand description
A curated, offline-complete explanation of a diagnostic code (#853).
This is the compiler-owned code → { blurb, href } table (DECISION A): the
blurb/example are the offline answer bynk explain prints, while
page/anchor compose the hosted-Book href the LSP hangs off the code as a
clickable codeDescription link (DECISION C). Only the highest-traffic,
newcomer-facing codes are curated; every other code simply has no entry and
falls back gracefully — no link, no error (DECISION B).
The mapping points at existing Book concept pages rather than duplicating
their prose; the reference-page generator (render_markdown) links every
explained code at its page/anchor as an in-site link, so
astro build’s link checker fails if a page moves or an anchor is renamed —
the doc-drift guard the rest of the site already relies on.
Fields§
§code: &'static strThe diagnostic code this explains. Must be a real REGISTRY code
(enforced by tests/diagnostics_registry.rs).
blurb: &'static strA longer-form paragraph: what the rule is and, crucially, why it exists. This is the offline-complete answer — useful without network.
example: &'static strA minimal example of the violation and its fix.
page: &'static strThe target Book page as a site-root-relative path, no extension and no
trailing slash, e.g. /book/reference/types. Used verbatim as an
in-site link by render_markdown (so the site link checker guards it)
and prefixed with BOOK_BASE_URL for the hosted codeDescription.
anchor: &'static strThe in-page heading anchor (slug), or "" for the page top.
Implementations§
Source§impl Explain
impl Explain
Sourcepub fn href(&self) -> String
pub fn href(&self) -> String
The hosted-Book URL for this explanation: BOOK_BASE_URL + the page
(Starlight serves pages with a trailing slash) + #anchor when set.
Sourcepub fn in_site_link(&self) -> String
pub fn in_site_link(&self) -> String
The site-root-relative link used inside the generated reference page,
e.g. /book/reference/types/#record-types. Same shape as href, sans
the host, so the in-site link checker resolves it.
Auto Trait Implementations§
impl Freeze for Explain
impl RefUnwindSafe for Explain
impl Send for Explain
impl Sync for Explain
impl Unpin for Explain
impl UnsafeUnpin for Explain
impl UnwindSafe for Explain
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);