pub struct FunctionOverloads<T>(/* private fields */);
Expand description
Collection of function overloads grouped by argument kinds.
FunctionOverloads<T>
manages multiple function overloads that share the same name
but have different argument signatures. This allows CEL to support function overloading
based on argument types, similar to many programming languages.
§Type Parameters
T
: The type of function stored (implementation, declaration, or either)
§Examples
use cel_cxx::function::{FunctionOverloads, FunctionDeclOrImpl};
let mut overloads = FunctionOverloads::<FunctionDeclOrImpl>::new();
// Add different overloads for the same function name
Implementations§
Source§impl<T: FunctionTypeOverload> FunctionOverloads<T>
impl<T: FunctionTypeOverload> FunctionOverloads<T>
Sourcepub fn find_mut(
&mut self,
member: bool,
kinds: &[Kind],
) -> Option<&mut FunctionKindOverload<T>>
pub fn find_mut( &mut self, member: bool, kinds: &[Kind], ) -> Option<&mut FunctionKindOverload<T>>
Sourcepub fn entries(&self) -> impl Iterator<Item = &FunctionKindOverload<T>>
pub fn entries(&self) -> impl Iterator<Item = &FunctionKindOverload<T>>
Returns an iterator over all function overloads.
§Examples
use cel_cxx::function::{FunctionOverloads, FunctionDeclOrImpl};
let overloads = FunctionOverloads::<FunctionDeclOrImpl<'_>>::new();
for overload in overloads.entries() {
// Process each overload
}
Sourcepub fn entries_mut(
&mut self,
) -> impl Iterator<Item = &mut FunctionKindOverload<T>>
pub fn entries_mut( &mut self, ) -> impl Iterator<Item = &mut FunctionKindOverload<T>>
Returns a mutable iterator over all function overloads.
Source§impl<'f> FunctionOverloads<FunctionDeclOrImpl<'f>>
impl<'f> FunctionOverloads<FunctionDeclOrImpl<'f>>
Sourcepub fn add_impl(
&mut self,
member: bool,
f: Function<'f>,
) -> Result<&mut Self, Error>
pub fn add_impl( &mut self, member: bool, f: Function<'f>, ) -> Result<&mut Self, Error>
Adds a function implementation to the overloads.
This method adds a concrete function implementation to the appropriate overload group based on its signature. If no matching overload exists, a new one is created.
§Arguments
member
- Whether this is a member functionf
- The function implementation to add
§Returns
Ok(&mut Self)
for method chaining, or Err(Error)
if addition fails
§Errors
Returns error if the function signature conflicts with existing registrations.
Sourcepub fn add_decl(
&mut self,
member: bool,
f: FunctionType,
) -> Result<&mut Self, Error>
pub fn add_decl( &mut self, member: bool, f: FunctionType, ) -> Result<&mut Self, Error>
Adds a function declaration to the overloads.
This method adds a function type signature (declaration) to the appropriate overload group. Declarations provide type information for compile-time checking without requiring an implementation.
§Arguments
member
- Whether this is a member function declarationf
- The function type signature to add
§Returns
Ok(&mut Self)
for method chaining, or Err(Error)
if addition fails
§Errors
Returns error if the function signature conflicts with existing registrations.
Source§impl<'f> FunctionOverloads<Function<'f>>
impl<'f> FunctionOverloads<Function<'f>>
Sourcepub fn add(&mut self, member: bool, f: Function<'f>) -> Result<&mut Self, Error>
pub fn add(&mut self, member: bool, f: Function<'f>) -> Result<&mut Self, Error>
Adds a function to the overloads.
This method adds a function to the appropriate overload group based on its signature. This is used when working with pure function implementations without separate declarations.
§Arguments
member
- Whether this is a member functionf
- The function to add
§Returns
Ok(&mut Self)
for method chaining, or Err(Error)
if addition fails
§Errors
Returns error if the function signature conflicts with existing registrations.
Trait Implementations§
Source§impl<T: Clone> Clone for FunctionOverloads<T>
impl<T: Clone> Clone for FunctionOverloads<T>
Source§fn clone(&self) -> FunctionOverloads<T>
fn clone(&self) -> FunctionOverloads<T>
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<T: Debug> Debug for FunctionOverloads<T>
impl<T: Debug> Debug for FunctionOverloads<T>
Source§impl<T: Default> Default for FunctionOverloads<T>
impl<T: Default> Default for FunctionOverloads<T>
Source§fn default() -> FunctionOverloads<T>
fn default() -> FunctionOverloads<T>
Auto Trait Implementations§
impl<T> Freeze for FunctionOverloads<T>
impl<T> RefUnwindSafe for FunctionOverloads<T>where
T: RefUnwindSafe,
impl<T> Send for FunctionOverloads<T>where
T: Send,
impl<T> Sync for FunctionOverloads<T>where
T: Sync,
impl<T> Unpin for FunctionOverloads<T>where
T: Unpin,
impl<T> UnwindSafe for FunctionOverloads<T>where
T: UnwindSafe,
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