pub struct FunctionDeclOrImpl<'f> { /* private fields */ }
Expand description
Union type representing either a function declaration or implementation.
FunctionDeclOrImpl
can hold either:
- A function type signature (declaration) for compile-time type checking
- A concrete function implementation for runtime execution
- Both a declaration and implementation (preferred)
This allows the system to provide type information even when implementations are not available, enabling better compile-time checking and error reporting.
§Examples
use cel_cxx::function::{FunctionDeclOrImpl, IntoFunction};
use cel_cxx::types::{ValueType, FunctionType};
// Create from declaration only
let func_type = FunctionType::new(ValueType::Int, vec![ValueType::Int]);
let decl_only = FunctionDeclOrImpl::new(func_type);
// Create from implementation (includes both decl and impl)
let func = (|a: i32, b: i32| -> i32 { a + b }).into_function();
let with_impl = FunctionDeclOrImpl::new_impl(func);
Implementations§
Source§impl<'f> FunctionDeclOrImpl<'f>
impl<'f> FunctionDeclOrImpl<'f>
Sourcepub fn new_impl(impl: Function<'f>) -> Self
pub fn new_impl(impl: Function<'f>) -> Self
Creates a new FunctionDeclOrImpl
from a function implementation.
This constructor creates both the declaration (extracted from the function’s type signature) and stores the implementation for runtime execution.
§Arguments
r#impl
- The function implementation
§Returns
New FunctionDeclOrImpl
containing both declaration and implementation
Sourcepub fn new(type: FunctionType) -> Self
pub fn new(type: FunctionType) -> Self
Creates a new FunctionDeclOrImpl
from a function type declaration.
This constructor creates a declaration-only entry, useful for providing type information without requiring an implementation.
§Arguments
r#type
- The function type signature
§Returns
New FunctionDeclOrImpl
containing only the declaration
Sourcepub fn is_impl(&self) -> bool
pub fn is_impl(&self) -> bool
Returns whether this entry has a concrete implementation.
§Returns
true
if this entry contains a function implementation, false
if declaration-only
Sourcepub fn decl(&self) -> &FunctionType
pub fn decl(&self) -> &FunctionType
Trait Implementations§
Source§impl<'f> Clone for FunctionDeclOrImpl<'f>
impl<'f> Clone for FunctionDeclOrImpl<'f>
Source§fn clone(&self) -> FunctionDeclOrImpl<'f>
fn clone(&self) -> FunctionDeclOrImpl<'f>
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<'f> Debug for FunctionDeclOrImpl<'f>
impl<'f> Debug for FunctionDeclOrImpl<'f>
Source§impl FunctionTypeOverload for FunctionDeclOrImpl<'_>
impl FunctionTypeOverload for FunctionDeclOrImpl<'_>
Auto Trait Implementations§
impl<'f> Freeze for FunctionDeclOrImpl<'f>
impl<'f> !RefUnwindSafe for FunctionDeclOrImpl<'f>
impl<'f> Send for FunctionDeclOrImpl<'f>
impl<'f> Sync for FunctionDeclOrImpl<'f>
impl<'f> Unpin for FunctionDeclOrImpl<'f>
impl<'f> !UnwindSafe for FunctionDeclOrImpl<'f>
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
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>
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>
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