AI Function Crate

The ai_function crate provides a Rust procedural macro that allows you to transform any function into a function that returns its own definition as a string. This is useful for sending the function's code to a large language model for further processing.

Installation

Add the following to your Cargo.toml file:

toml [dependencies] ai_function = "0.1.0"

Then run cargo build to download and compile the ai_function crate.

Usage

To use the aifunction macro, simply annotate your function with #[aifunction].

use aifunction::aifunction;

```

[ai_function]

fn example_function(arg: i32) -> i32 { arg * 2 } ```

When you call examplefunction(), instead of returning arg * 2, it will return a string containing the source code of the examplefunction.

Limitations

The #[ai_function] macro currently does not support functions with complex control flow like loops or conditionals. It only supports simple function definitions.

``` use aifunctions::aifunction;

[ai_function]

fn add(a: i32, b: i32) -> i32 { a + b }

fn main() { assert_eq!(add(2, 3), "fn add(a: i32, b: i32) -> i32 {\n a + b\n}"); } ```