Skip to main content

Step

Enum Step 

Source
pub enum Step<'s> {
    Field(&'s str),
    OptField(&'s str),
    MapField(&'s str),
    Index(usize),
    VarIndex(IndexTy),
}
Expand description

生成计划里的一步:描述“这一段取到什么类型的值“。

? 前缀不在这里表达——它由上一步是否为 Option 决定,codegen 顺序渲染时 记账即可(见 examples/chain_check.rs)。

Variants§

§

Field(&'s str)

非空字段:self.name。容器是 Map 时改用 Step::MapField。

§

OptField(&'s str)

可空字段:self.name.as_ref(),取到 Option<&T>

§

MapField(&'s str)

Map 容器上的静态键:m.get("name"),恒为 Option<&T>。 Step::Field 文档旧称“Map 上退化成 m.get“却仍报 is_option() == false, 与 Index/VarIndex 的 Option 语义冲突;单独成一步消除歧义。

§

Index(usize)

常量下标:self.arr.get(k),取到 Option<&T>; 容器是 Map 时按十进制字符串取键(m["0"]),由 codegen 按自身类型表决定

§

VarIndex(IndexTy)

变量下标:self.arr.get(idx),取到 Option<&T>

Implementations§

Source§

impl Step<'_>

Source

pub fn is_option(&self) -> bool

这一步取到的值是否为 Option(决定下一步要不要加 ?)。

Trait Implementations§

Source§

impl<'s> Clone for Step<'s>

Source§

fn clone(&self) -> Self

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<'s> Copy for Step<'s>

Source§

impl<'s> Debug for Step<'s>

Source§

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

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

impl<'s> Eq for Step<'s>

Source§

impl<'s> PartialEq for Step<'s>

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl<'s> StructuralPartialEq for Step<'s>

Auto Trait Implementations§

§

impl<'s> Forget for Step<'s>

§

impl<'s> Freeze for Step<'s>
where &'s str: Freeze,

§

impl<'s> Move for Step<'s>

§

impl<'s> RefUnwindSafe for Step<'s>

§

impl<'s> Send for Step<'s>
where &'s str: Send,

§

impl<'s> Sync for Step<'s>

§

impl<'s> Unpin for Step<'s>
where &'s str: Unpin,

§

impl<'s> UnsafeUnpin for Step<'s>
where &'s str: UnsafeUnpin,

§

impl<'s> UnwindSafe for Step<'s>
where &'s str: UnwindSafe,

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.