pub struct UserFunction {
pub weight: u16,
pub name: String,
pub description: String,
pub body: Vec<UdfOp>,
pub num_type: NumType,
}Expand description
A user-defined function
Fields§
§weight: u16Weight (complexity) of this function
This field is part of the public API and is used when generating expressions that include user-defined functions.
name: StringShort name (single or few characters)
description: StringDescription (for display)
This field is part of the public API for documentation and display purposes.
body: Vec<UdfOp>The body of the function as a postfix expression Uses standard symbols plus special stack operations
num_type: NumTypeNumeric type of result
This field is part of the public API for type inference when combining expressions that use user-defined functions.
Implementations§
Source§impl UserFunction
impl UserFunction
Sourcepub fn parse(spec: &str) -> Result<Self, String>
pub fn parse(spec: &str) -> Result<Self, String>
Parse a user-defined function from a definition string Format: “weight:name:description:formula” Example: “4:sinh:hyperbolic sine:E|r-2/”
Sourcepub fn stack_effect(&self) -> i32
pub fn stack_effect(&self) -> i32
Get the stack effect of this function (pushed - popped) For a unary function, this should be 0 (pop 1, push 1)
This method is part of the public API for library consumers who need to validate user-defined functions before use.
Trait Implementations§
Source§impl Clone for UserFunction
impl Clone for UserFunction
Source§fn clone(&self) -> UserFunction
fn clone(&self) -> UserFunction
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for UserFunction
impl RefUnwindSafe for UserFunction
impl Send for UserFunction
impl Sync for UserFunction
impl Unpin for UserFunction
impl UnsafeUnpin for UserFunction
impl UnwindSafe for UserFunction
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> 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