pub struct FunctionType {
pub result: Box<ValueType>,
pub arguments: Vec<ValueType>,
}
Expand description
Function type representing function signatures.
Function types describe the signature of functions, including their parameter types and return type. This is used for type checking function calls and declarations.
§Examples
use cel_cxx::*;
// Function type: (string, int) -> bool
let func_type = FunctionType::new(
ValueType::Bool,
vec![ValueType::String, ValueType::Int]
);
// No-argument function: () -> string
let no_arg_func = FunctionType::new(ValueType::String, vec![]);
Fields§
§result: Box<ValueType>
The return type of the function.
arguments: Vec<ValueType>
The parameter types of the function.
Implementations§
Source§impl FunctionType
impl FunctionType
Sourcepub fn new(result: ValueType, arguments: Vec<ValueType>) -> Self
pub fn new(result: ValueType, arguments: Vec<ValueType>) -> Self
Creates a new function type with the given return type and parameters.
§Arguments
result
- The return type of the functionarguments
- The parameter types of the function
§Examples
use cel_cxx::*;
// Function that takes two ints and returns a string
let func_type = FunctionType::new(
ValueType::String,
vec![ValueType::Int, ValueType::Int]
);
Sourcepub fn result(&self) -> &ValueType
pub fn result(&self) -> &ValueType
Returns the return type of this function.
§Examples
use cel_cxx::*;
let func_type = FunctionType::new(ValueType::Bool, vec![ValueType::String]);
assert_eq!(func_type.result(), &ValueType::Bool);
Sourcepub fn arguments(&self) -> &[ValueType]
pub fn arguments(&self) -> &[ValueType]
Returns the parameter types of this function.
§Examples
use cel_cxx::*;
let func_type = FunctionType::new(ValueType::Int, vec![ValueType::String, ValueType::Bool]);
assert_eq!(func_type.arguments().len(), 2);
Sourcepub fn id(&self, name: &str, member: bool) -> String
pub fn id(&self, name: &str, member: bool) -> String
Generates a unique identifier for this function type.
This creates a string representation of the function signature that can be used for function resolution and overload disambiguation.
§Arguments
name
- The name of the functionmember
- Whether this is a member function
§Examples
use cel_cxx::*;
let func_type = FunctionType::new(ValueType::Int, vec![ValueType::String]);
let id = func_type.id("myFunc", false);
// Results in something like "myFunc(string)"
Trait Implementations§
Source§impl Clone for FunctionType
impl Clone for FunctionType
Source§fn clone(&self) -> FunctionType
fn clone(&self) -> FunctionType
Returns a duplicate of the value. Read more
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for FunctionType
impl Debug for FunctionType
Source§impl Display for FunctionType
impl Display for FunctionType
Source§impl From<FunctionType> for ValueType
impl From<FunctionType> for ValueType
Source§fn from(value: FunctionType) -> Self
fn from(value: FunctionType) -> Self
Converts to this type from the input type.
Source§impl Hash for FunctionType
impl Hash for FunctionType
Source§impl PartialEq for FunctionType
impl PartialEq for FunctionType
impl Eq for FunctionType
impl StructuralPartialEq for FunctionType
Auto Trait Implementations§
impl Freeze for FunctionType
impl RefUnwindSafe for FunctionType
impl Send for FunctionType
impl Sync for FunctionType
impl Unpin for FunctionType
impl UnwindSafe for FunctionType
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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