proc_macro

结构体 Punct

1.29.0 · Source
pub struct Punct(/* private fields */);
展开描述

Punct 是一个单独的标点符号字符,例如 +-#

+= 这样的多字符运算符表示为两个 Punct 实例,并返回不同形式的 Spacing

实现§

Source§

impl Punct

1.29.0 · Source

pub fn new(ch: char, spacing: Spacing) -> Punct

从给定的字符和间距创建一个新的 Punctch 参数必须是语言允许的有效标点符号字符,否则该函数将 panic。

返回的 Punct 将具有 Span::call_site() 的默认 span,可以使用下面的 set_span 方法进一步配置。

1.29.0 · Source

pub fn as_char(&self) -> char

将此标点符号字符的值作为 char 返回。

1.29.0 · Source

pub fn spacing(&self) -> Spacing

返回此标点符号字符的间距,指示它是否可以与后面的 token(Joint)潜在地组合成多字符运算符,或者运算符是否已明确结束(Alone)。

1.29.0 · Source

pub fn span(&self) -> Span

返回此标点符号字符的 span。

1.29.0 · Source

pub fn set_span(&mut self, span: Span)

配置此标点符号字符的 span。

Trait 实现§

1.29.0 · Source§

impl Clone for Punct

Source§

fn clone(&self) -> Punct

返回值的副本。阅读更多
1.0.0 · Source§

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

执行从 source 的复制赋值。阅读更多
1.29.0 · Source§

impl Debug for Punct

Source§

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

使用给定的 formatter 格式化值。阅读更多
1.29.0 · Source§

impl Display for Punct

将标点符号字符打印为字符串,该字符串应可无损地转换回相同的字符。

Source§

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

使用给定的 formatter 格式化值。阅读更多
1.29.0 · Source§

impl From<Punct> for TokenTree

Source§

fn from(g: Punct) -> TokenTree

从此输入类型转换为此类型。
1.52.0 · Source§

impl PartialEq<Punct> for char

Source§

fn eq(&self, rhs: &Punct) -> bool

测试 selfother 值是否相等,并由 == 使用。
1.0.0 · Source§

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

测试 !=。默认实现几乎总是足够的,除非有非常好的理由,否则不应覆盖它。
1.50.0 · Source§

impl PartialEq<char> for Punct

Source§

fn eq(&self, rhs: &char) -> bool

测试 selfother 值是否相等,并由 == 使用。
1.0.0 · Source§

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

测试 !=。默认实现几乎总是足够的,除非有非常好的理由,否则不应覆盖它。
Source§

impl ToTokens for Punct

Source§

fn to_tokens(&self, tokens: &mut TokenStream)

🔬这是一个仅限 nightly 版本的实验性 API。(proc_macro_totokens #130977
self 写入给定的 TokenStream阅读更多
Source§

fn to_token_stream(&self) -> TokenStream

🔬这是一个仅限 nightly 版本的实验性 API。(proc_macro_totokens #130977
self 直接转换为 TokenStream 对象。阅读更多
Source§

fn into_token_stream(self) -> TokenStream
where Self: Sized,

🔬这是一个仅限 nightly 版本的实验性 API。(proc_macro_totokens #130977
self 直接转换为 TokenStream 对象。阅读更多
1.29.0 · Source§

impl !Send for Punct

1.29.0 · Source§

impl !Sync for Punct

自动 Trait 实现§

泛型实现§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

获取 selfTypeId阅读更多
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

从拥有的值不可变地借用。阅读更多
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

从拥有的值可变地借用。阅读更多
1.29.0 · Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬这是一个仅限 nightly 版本的实验性 API。(clone_to_uninit #126799
执行从 selfdst 的复制赋值。阅读更多
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

返回未更改的参数。

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

调用 U::from(self)

也就是说,此转换是 From<T> for U 的实现选择执行的任何操作。

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

获取所有权后产生的类型。
Source§

fn to_owned(&self) -> T

从借用的数据创建拥有的数据,通常通过克隆。阅读更多
Source§

fn clone_into(&self, target: &mut T)

使用借用的数据替换拥有的数据,通常通过克隆。阅读更多
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

将给定值转换为 String阅读更多
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

转换错误时返回的类型。
Source§

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

执行转换。
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

转换错误时返回的类型。
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

执行转换。