Skip to main content

FunctionAssertionProvider

Trait FunctionAssertionProvider 

Source
pub trait FunctionAssertionProvider: Provider {
    // Required methods
    fn targets() -> FunctionTarget
       where Self: Sized;
    fn get_assertions(
        &self,
        context: &ProviderContext<'_, '_, '_>,
        invocation: &InvocationInfo<'_, '_, '_>,
    ) -> Option<InvocationAssertions>;
}
Expand description

Provider for getting additional assertions from function calls.

This allows plugins to specify type narrowing for calls like:

  • assert($x instanceof Foo) - narrows $x to Foo after the call
  • Assert::assertIsString($x) - narrows $x to string after the call

Required Methods§

Source

fn targets() -> FunctionTarget
where Self: Sized,

The functions this provider handles.

Source

fn get_assertions( &self, context: &ProviderContext<'_, '_, '_>, invocation: &InvocationInfo<'_, '_, '_>, ) -> Option<InvocationAssertions>

Get assertions for the invocation.

Returns Some(assertions) if this provider has assertions to add, None otherwise.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§