Skip to main content

GraftSyntax

Struct GraftSyntax 

Source
pub struct GraftSyntax {
    pub cut: String,
    pub cut_end: Option<String>,
    pub graft: String,
    pub full: bool,
    pub location: SyntaxLocation,
    pub cfg: Option<String>,
    pub expressions: Option<GraftExpressions>,
}
Expand description

A host-declared external graft cut discovered before code generation. 在代码生成前从宿主入口发现的一条外部 graft 切口。

Fields§

§cut: String

The cut target: a logical path, or the Rust expression text of a typed cut. For a range this is the start endpoint, never "start to end". 切口目标:逻辑路径,或类型化切口的 Rust 表达式原文。区间切口这里是起点, 绝不是 "start to end"。

§cut_end: Option<String>

The far endpoint of a sibling range, as data. 兄弟区间的远端端点,以数据形式携带。

Why the joined-string encoding was wrong: a logical path is free-form text, so once "a to b" is stored in cut nothing downstream can tell a range from a single path that literally contains " to " — the four consumers that re-split cut cut such a path in half. The boundary is this field: only the parser may decide that a to token was a range separator, and every consumer reads the endpoints from cut/cut_end. Pinned by a_path_containing_the_range_word_is_a_single_cut (this file) and a_string_range_keeps_both_endpoints (build_method). 拼接字符串的编码错在哪:逻辑路径是自由文本,一旦把 "a to b" 存进 cut, 下游就再也分不清区间与一条字面含有 " to " 的路径——四处重新拆分 cut 的 消费方会把这种路径拦腰截断。边界就是本字段:只有解析器能判定某个 to token 是区间分隔符,所有消费方都从 cut/cut_end 读取端点。 由本文件的 a_path_containing_the_range_word_is_a_single_cut 与 build_method 的 a_string_range_keeps_both_endpoints 钉住。

§graft: String

The replacement side, written the same way as cut: a logical selector, a Rust expression, or an identity. 替换侧,与 cut 使用同一种写法:逻辑选择器、Rust 表达式或身份。

§full: bool

Whether the replacement covers the whole subtree at the cut target rather than only its node. 替换是否覆盖切口目标的整棵子树,而不只是该节点自身。

§location: SyntaxLocation

Where the declaration was written, for diagnostics that point at it. 声明写在哪,供指向它的诊断使用。

§cfg: Option<String>

The cfg gate the declaration carries, if any, exactly as written. 声明携带的 cfg 门控(若有),按原文保留。

§expressions: Option<GraftExpressions>

Present when cut(...) / graft(...) supplied Rust expressions. The renderer emits those expressions verbatim, so the compiler — and any editor that resolves Rust paths — sees the real target instead of a string the tooling would have to interpret. 当 cut(...) / graft(...) 给出 Rust 表达式时存在。渲染器会原样发射这些 表达式,因此编译器和任何能解析 Rust 路径的编辑器看到的都是真实目标, 而不是需要工具自己解释的字符串。

Trait Implementations§

Source§

impl Clone for GraftSyntax

Source§

fn clone(&self) -> GraftSyntax

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 GraftSyntax

Source§

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

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

impl Eq for GraftSyntax

Source§

impl PartialEq for GraftSyntax

Source§

fn eq(&self, other: &GraftSyntax) -> 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 GraftSyntax

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.