pub struct ResolvedArrayType { /* private fields */ }Expand description
The resolved descriptor for one complete array type annotation.
§Examples
See Self::from_resolved_type for conversion and element metadata.
Implementations§
Source§impl ResolvedArrayType
impl ResolvedArrayType
Sourcepub fn from_element_type(element_type: ValueType) -> Self
pub fn from_element_type(element_type: ValueType) -> Self
Creates a resolved array type from its already-resolved element descriptor.
-
Precondition:
element_typeretains a concrete canonical factory. -
Postcondition:
element_typereturnselement_typeunchanged, so the result describes an array whose elements have exactly that type.
§Examples
use cel_parser::ResolvedArrayType;
use cel_runtime::ValueType;
let array = ResolvedArrayType::from_element_type(ValueType::leaf::<i32>());
assert_eq!(array.element_type().type_name(), "i32");Sourcepub fn from_resolved_type(
resolved: ResolvedType,
span: ExprSpan,
) -> Result<Self>
pub fn from_resolved_type( resolved: ResolvedType, span: ExprSpan, ) -> Result<Self>
Creates a resolved array type from a fully resolved recursive type expression.
§Errors
Returns Err if resolved is not an array type or its layout is unrepresentable.
- Complexity: Matches recursive descriptor conversion, or diagnostic name construction when the resolved type is not an array.
§Examples
use cel_parser::{CELParser, OpLookup, ResolvedArrayType};
let mut parser = CELParser::new(OpLookup::new());
let syntax = parser.parse_type_expr_str("[i32]").unwrap();
let resolved = parser.resolve_type_expr(&syntax).unwrap();
let array = ResolvedArrayType::from_resolved_type(resolved, syntax.span()).unwrap();
assert_eq!(array.element_type().type_name(), "i32");
assert_eq!(array.into_element_type().type_id(), std::any::TypeId::of::<i32>());Sourcepub fn element_type(&self) -> &ValueType
pub fn element_type(&self) -> &ValueType
Returns the recursive element descriptor this array annotation resolves to.
§Examples
Sourcepub fn into_element_type(self) -> ValueType
pub fn into_element_type(self) -> ValueType
Returns the recursive element descriptor, consuming self.
§Examples
See Self::from_resolved_type for transferring the descriptor.
Trait Implementations§
Source§impl Clone for ResolvedArrayType
impl Clone for ResolvedArrayType
Source§impl Debug for ResolvedArrayType
impl Debug for ResolvedArrayType
Auto Trait Implementations§
impl Freeze for ResolvedArrayType
impl RefUnwindSafe for ResolvedArrayType
impl Send for ResolvedArrayType
impl Sync for ResolvedArrayType
impl Unpin for ResolvedArrayType
impl UnsafeUnpin for ResolvedArrayType
impl UnwindSafe for ResolvedArrayType
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