Skip to main content

Function

Trait Function 

Source
pub trait Function:
    Clone
    + Send
    + Sync
    + PartialEq
    + Debug
    + Serialize
    + for<'de> Deserialize<'de>
    + 'static {
    // Required methods
    fn arity(&self) -> usize;
    fn random<R: Rng>(rng: &mut R) -> Self;
    fn functions() -> &'static [Self];
    fn apply(&self, args: &[f64]) -> f64;
    fn to_string(&self) -> String;
}
Expand description

Trait for function nodes in GP trees

Required Methods§

Source

fn arity(&self) -> usize

Get the arity (number of arguments) of this function

Source

fn random<R: Rng>(rng: &mut R) -> Self

Generate a random function

Source

fn functions() -> &'static [Self]

Get the set of available functions

Source

fn apply(&self, args: &[f64]) -> f64

Apply this function to the given arguments

Source

fn to_string(&self) -> String

Convert to string representation

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§