Skip to main content

SegType

Enum SegType 

Source
pub enum SegType<'s> {
    Present,
    Optional,
    Map(&'s str),
    OptMap(&'s str),
    Unknown,
}
Expand description

段取到的值的类型。

Variants§

§

Present

一定有值(JSDoc 里非可选)

§

Optional

可空:数据里可能缺键,或显式 null

§

Map(&'s str)

Object.<string, T> 字典,&str 是元素类型原文(用于检查是否混合类型)

§

OptMap(&'s str)

可空字典 Object.<string, T>|null:访问语义同 SegType::Map, 但容器可空,后续非可选访问要以 E_NONOPT_ON_OPTIONAL 报错。 单独成态是因为 Map 的可空性不能丢:丢了就等于放过一次真实的 TypeError。

§

Unknown

推断不出:按“必有值“处理,且不因可空性报错

Implementations§

Source§

impl<'s> SegType<'s>

Source

pub fn is_nullable(self) -> bool

该段是否可能为 null/undefined。

Source

pub fn map_value(self) -> Option<&'s str>

若是字典(可空或非空),返回元素类型原文。

Trait Implementations§

Source§

impl<'s> Clone for SegType<'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 SegType<'s>

Source§

impl<'s> Debug for SegType<'s>

Source§

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

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

impl<'s> Eq for SegType<'s>

Source§

impl<'s> PartialEq for SegType<'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 SegType<'s>

Auto Trait Implementations§

§

impl<'s> Forget for SegType<'s>

§

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

§

impl<'s> Move for SegType<'s>

§

impl<'s> RefUnwindSafe for SegType<'s>

§

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

§

impl<'s> Sync for SegType<'s>

§

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

§

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

§

impl<'s> UnwindSafe for SegType<'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.