pub enum PragmaTokens<'ast> {
Version(Ident, SemverReq<'ast>),
Custom(IdentOrStrLit, Option<IdentOrStrLit>),
Verbatim(&'ast mut RawThinSlice<(), Token>),
}Expand description
The parsed or unparsed tokens of a pragma directive.
Variants§
Version(Ident, SemverReq<'ast>)
A Semantic Versioning requirement: pragma solidity <req>;.
Note that this is parsed differently from the semver crate.
Custom(IdentOrStrLit, Option<IdentOrStrLit>)
pragma <name> [value];.
Verbatim(&'ast mut RawThinSlice<(), Token>)
Unparsed tokens: pragma <tokens...>;.
Implementations§
Source§impl PragmaTokens<'_>
impl PragmaTokens<'_>
Sourcepub fn as_name_and_value(
&self,
) -> Option<(&IdentOrStrLit, Option<&IdentOrStrLit>)>
pub fn as_name_and_value( &self, ) -> Option<(&IdentOrStrLit, Option<&IdentOrStrLit>)>
Returns the name and value of the pragma directive, if any.
§Examples
pragma solidity ...; // None
pragma abicoder v2; // Some((Ident("abicoder"), Some(Ident("v2"))))
pragma experimental solidity; // Some((Ident("experimental"), Some(Ident("solidity"))))
pragma hello; // Some((Ident("hello"), None))
pragma hello world; // Some((Ident("hello"), Some(Ident("world"))))
pragma hello "world"; // Some((Ident("hello"), Some(StrLit("world"))))
pragma "hello" world; // Some((StrLit("hello"), Some(Ident("world"))))
pragma ???; // NoneTrait Implementations§
Auto Trait Implementations§
impl<'ast> Freeze for PragmaTokens<'ast>
impl<'ast> RefUnwindSafe for PragmaTokens<'ast>
impl<'ast> Send for PragmaTokens<'ast>
impl<'ast> Sync for PragmaTokens<'ast>
impl<'ast> Unpin for PragmaTokens<'ast>
impl<'ast> !UnwindSafe for PragmaTokens<'ast>
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
Mutably borrows from an owned value. Read more
Source§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more