Skip to main content

TsValue

Enum TsValue 

Source
pub enum TsValue {
Show 19 variants Undefined, Null, Boolean(bool), Number(f64), String(String), Object(Vec<(String, TsValue)>), Array(Vec<TsValue>), Function(Rc<dyn Fn(&[TsValue]) -> TsValue>), Error(String), Union(Vec<TsValue>), Generic(String, Vec<TsValue>), Symbol(String), BigInt(i128), Date(i64), RegExp(String), Map(Vec<(TsValue, TsValue)>), Set(Vec<TsValue>), Promise(Box<TsValue>), Iterable(Box<dyn Iterator<Item = TsValue>>),
}
Expand description

TypeScript 值类型枚举

Variants§

§

Undefined

未定义

§

Null

空值

§

Boolean(bool)

布尔值

§

Number(f64)

数字

§

String(String)

字符串

§

Object(Vec<(String, TsValue)>)

对象

§

Array(Vec<TsValue>)

数组

§

Function(Rc<dyn Fn(&[TsValue]) -> TsValue>)

函数

§

Error(String)

错误

§

Union(Vec<TsValue>)

联合类型

§

Generic(String, Vec<TsValue>)

泛型类型

§

Symbol(String)

符号

§

BigInt(i128)

大整数

§

Date(i64)

日期

§

RegExp(String)

正则表达式

§

Map(Vec<(TsValue, TsValue)>)

Map

§

Set(Vec<TsValue>)

Set

§

Promise(Box<TsValue>)

Promise

§

Iterable(Box<dyn Iterator<Item = TsValue>>)

可迭代对象

Implementations§

Source§

impl TsValue

Source

pub fn is_undefined(&self) -> bool

检查是否为未定义

Source

pub fn is_null(&self) -> bool

检查是否为空值

Source

pub fn is_boolean(&self) -> bool

检查是否为布尔值

Source

pub fn is_number(&self) -> bool

检查是否为数字

Source

pub fn is_string(&self) -> bool

检查是否为字符串

Source

pub fn is_object(&self) -> bool

检查是否为对象

Source

pub fn is_array(&self) -> bool

检查是否为数组

Source

pub fn is_function(&self) -> bool

检查是否为函数

Source

pub fn is_error(&self) -> bool

检查是否为错误

Source

pub fn is_union(&self) -> bool

检查是否为联合类型

Source

pub fn is_generic(&self) -> bool

检查是否为泛型类型

Source

pub fn is_symbol(&self) -> bool

检查是否为符号

Source

pub fn is_bigint(&self) -> bool

检查是否为大整数

Source

pub fn is_date(&self) -> bool

检查是否为日期

Source

pub fn is_regexp(&self) -> bool

检查是否为正则表达式

Source

pub fn is_map(&self) -> bool

检查是否为 Map

Source

pub fn is_set(&self) -> bool

检查是否为 Set

Source

pub fn is_promise(&self) -> bool

检查是否为 Promise

Source

pub fn is_iterable(&self) -> bool

检查是否为可迭代对象

Source

pub fn to_boolean(&self) -> bool

转换为布尔值

Source

pub fn to_number(&self) -> f64

转换为数字

Source

pub fn to_string(&self) -> String

转换为字符串

Trait Implementations§

Source§

impl Clone for TsValue

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for TsValue

Source§

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

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

impl Hash for TsValue

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.