#[cfg(feature = "parsing")] usecrate::lookahead; use proc_macro2::{Ident, Span}; use std::cmp::Ordering; use std::fmt::{self, Display}; use std::hash::{Hash, Hasher};
/// A Rust lifetime: `'a`. /// /// Lifetime names must conform to the following rules: /// /// - Must start with an apostrophe. /// - Must not consist of just an apostrophe: `'`. /// - Character after the apostrophe must be `_` or a Unicode code point with /// the XID_Start property. /// - All following characters must be Unicode code points with the XID_Continue /// property. pubstruct Lifetime { pub apostrophe: Span, pub ident: Ident,
}
impl Lifetime { /// # Panics /// /// Panics if the lifetime does not conform to the bulleted rules above. /// /// # Invocation /// /// ``` /// # use proc_macro2::Span; /// # use syn::Lifetime; /// # /// # fn f() -> Lifetime { /// Lifetime::new("'a", Span::call_site()) /// # } /// ``` pubfn new(symbol: &str, span: Span) -> Self { if !symbol.starts_with('\'') {
panic!( "lifetime name must start with apostrophe as in \"'a\", got {:?}",
symbol
);
}
if symbol == "'" {
panic!("lifetime name must not be empty");
}
if !crate::ident::xid_ok(&symbol[1..]) {
panic!("{:?} is not a valid lifetime name", symbol);
}
#[cfg(feature = "printing")] mod printing { usecrate::lifetime::Lifetime; use proc_macro2::{Punct, Spacing, TokenStream}; use quote::{ToTokens, TokenStreamExt};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.