Struct VariableDeclOrConstant

Source
pub struct VariableDeclOrConstant { /* private fields */ }
Expand description

Union type representing either a variable declaration or constant definition.

VariableDeclOrConstant can hold either:

  • A constant value (Constant) that is known at compile time
  • A variable declaration (ValueType) that specifies the type for runtime binding

This allows the registry to handle both compile-time constants and runtime variables in a unified way.

§Examples

use cel_cxx::variable::VariableDeclOrConstant;
use cel_cxx::types::ValueType;

// Create from constant
let constant_entry = VariableDeclOrConstant::new_constant(42i64);
assert!(constant_entry.is_constant());

// Create from declaration
let decl_entry = VariableDeclOrConstant::new(ValueType::String);
assert!(!decl_entry.is_constant());

Implementations§

Source§

impl VariableDeclOrConstant

Source

pub fn new_constant<T>(value: T) -> Self
where T: IntoConstant,

Creates a new constant entry.

§Type Parameters
§Parameters
  • value: The constant value
§Returns

New VariableDeclOrConstant containing the constant value

Source

pub fn new(type: ValueType) -> Self

Creates a new variable declaration entry.

§Parameters
  • r#type: The variable type
§Returns

New VariableDeclOrConstant containing the type declaration

Source

pub fn is_constant(&self) -> bool

Returns whether this entry is a constant.

§Returns

true if this entry contains a constant value, false if it’s a declaration

Source

pub fn decl(&self) -> &ValueType

Gets the type of this entry.

For constants, this is the type of the constant value. For declarations, this is the declared variable type.

§Returns

Reference to the ValueType of this entry

Source

pub fn constant(&self) -> Option<&Constant>

Gets the constant value, if this entry is a constant.

§Returns

Some(&Constant) if this is a constant entry, None if it’s a declaration

Trait Implementations§

Source§

impl Debug for VariableDeclOrConstant

Source§

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

Formats the value using the given formatter. Read more

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
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<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