Enum brane_dsl::ast::Literal

source ·
pub enum Literal {
    Null {
        range: TextRange,
    },
    Boolean {
        value: bool,
        range: TextRange,
    },
    Integer {
        value: i64,
        range: TextRange,
    },
    Real {
        value: f64,
        range: TextRange,
    },
    String {
        value: String,
        range: TextRange,
    },
    Semver {
        value: String,
        range: TextRange,
    },
    Void {
        range: TextRange,
    },
}
Expand description

Defines a literal constant.

Variants§

§

Null

Defines the null literal.

Fields

§range: TextRange

The range of the boolean in the source text.

§

Boolean

Defines a boolean literal.

Fields

§value: bool

The value of the Boolean.

§range: TextRange

The range of the boolean in the source text.

§

Integer

Defines an integral literal.

Fields

§value: i64

The value of the Integer.

§range: TextRange

The range of the integer in the source text.

§

Real

Defines a floating-point literal.

Fields

§value: f64

The value of the Real.

§range: TextRange

The range of the real in the source text.

§

String

Defines a String literal.

Fields

§value: String

The value of the String.

§range: TextRange

The range of the string in the source text.

§

Semver

Defines a SemVer literal.

Fields

§value: String

We did not parse the semver yet.

§

Void

Defines a Void literal (no value).

Fields

§range: TextRange

The range of the void in the source text.

Implementations§

source§

impl Literal

source

pub fn as_bool(&self) -> bool

Returns the value of the Literal as if it is a Boolean.

§Returns

The value of this Boolean literal.

§Panics

This function panics if the Literal is not a Boolean.

source

pub fn as_bool_ref(&self) -> &bool

Returns a reference to the value of the Literal as if it is a Boolean.

§Returns

A reference to the value of this Boolean literal.

§Panics

This function panics if the Literal is not a Boolean.

source

pub fn as_bool_mut(&mut self) -> &mut bool

Returns a muteable reference to the value of the Literal as if it is a Boolean.

§Returns

A muteable reference to the value of this Boolean literal.

§Panics

This function panics if the Literal is not a Boolean.

source

pub fn as_int(&self) -> i64

Returns the value of the Literal as if it is an Integer.

§Returns

The value of this Integer literal.

§Panics

This function panics if the Literal is not an Integer.

source

pub fn as_int_ref(&self) -> &i64

Returns a reference to the value of the Literal as if it is an Integer.

§Returns

A reference to the value of this Integer literal.

§Panics

This function panics if the Literal is not an Integer.

source

pub fn as_int_mut(&mut self) -> &mut i64

Returns a muteable reference to the value of the Literal as if it is an Integer.

§Returns

A muteable reference to the value of this Integer literal.

§Panics

This function panics if the Literal is not an Integer.

source

pub fn as_real(&self) -> f64

Returns the value of the Literal as if it is a Real.

§Returns

The value of this Real literal.

§Panics

This function panics if the Literal is not a Real.

source

pub fn as_real_ref(&self) -> &f64

Returns a reference to the value of the Literal as if it is a Real.

§Returns

A reference to the value of this Real literal.

§Panics

This function panics if the Literal is not a Real.

source

pub fn as_real_mut(&mut self) -> &mut f64

Returns a muteable reference to the value of the Literal as if it is a Real.

§Returns

A muteable reference to the value of this Real literal.

§Panics

This function panics if the Literal is not a Real.

source

pub fn as_string_ref(&self) -> &str

Returns a reference to the value of the Literal as if it is a String.

§Returns

A reference to the value of this String literal.

§Panics

This function panics if the Literal is not a String.

source

pub fn as_string_mut(&mut self) -> &mut str

Returns a muteable reference to the value of the Literal as if it is a String.

§Returns

A muteable reference to the value of this String literal.

§Panics

This function panics if the Literal is not a String.

source

pub fn as_version(&self) -> Result<Version, ParseError>

Returns a (parsed) semantic version from the Literal as if it is a Semver.

§Returns

A freshly parsed (i.e., non-trivial retrieval) of a Version.

§Errors

This function errors if we could not parse the Semver as a Version.

§Panics

This function panics if the Literal is not a Semver.

source

pub fn data_type(&self) -> DataType

Returns the data type of this Literal.

Trait Implementations§

source§

impl Clone for Literal

source§

fn clone(&self) -> Literal

Returns a copy 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 Literal

source§

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

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

impl EnumDebug for Literal

source§

fn type_name() -> &'static str

Returns the static name of the type used for EnumDebug-printing. Read more
source§

fn variant_names() -> &'static [&'static str]

Returns all variants in the trait as a list of names. Read more
source§

fn variant_name(&self) -> &'static str

Returns the static name of the variant. Read more
source§

fn variant(&self) -> EnumDebugFormatter<'_, Self>

Returns a formatter for this enum that writes its variant name. Read more
source§

fn variants() -> Copied<Iter<'static, &'static str>>

Returns an iterator over all variants in this enum. Read more
source§

impl Node for Literal

source§

fn range(&self) -> &TextRange

Returns the node’s source range.

source§

fn start(&self) -> &TextPos

Returns the node’s start position.
source§

fn end(&self) -> &TextPos

Returns the node’s end position.

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, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoRequest<T> for T

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
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.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> ErasedDestructor for T
where T: 'static,

source§

impl<T> MaybeSendSync for T