Struct proc_macro::Ident
1.29.0 · source · pub struct Ident(_);Expand description
标识符 (ident)。
Implementations§
source§impl Ident
impl Ident
sourcepub fn new(string: &str, span: Span) -> Ident
pub fn new(string: &str, span: Span) -> Ident
使用给定的 string 和指定的 span 创建新的 Ident。
string 参数必须是该语言允许的有效标识符 (包括关键字,例如 self 或 fn)。否则,函数将为 panic。
请注意,当前位于 rustc 中的 span 为此标识符配置了卫生信息。
截止到目前,Span::call_site() 明确选择采用 “call-site” 卫生标准,这意味着使用该跨度创建的标识符将被解析,就好像它们直接写在宏调用的位置一样,并且宏调用站点上的其他代码将能够引用他们也是。
以后的跨度 (例如 Span::def_site()) 将允许选择使用 “definition-site” 卫生,这意味着用该跨度创建的标识符将在宏定义的位置解析,而宏调用站点上的其他代码将无法引用它们。
由于当前对卫生的重要性,与其他 tokens 不同,该构造函数需要在构造时指定 Span。
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for Ident
impl !Send for Ident
impl !Sync for Ident
impl Unpin for Ident
impl UnwindSafe for Ident
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
从拥有的值中借用。 Read more