pub struct Function {
    pub docs: Option<DocString>,
    pub params: Vec<Param>,
    pub ret: Return,
}
Expand description

Documents a single function.

Fields

docs: Option<DocString>

Documentation for the function. If parsed, this should generally be the first statement of a function’s body if that statement is a string literal. Any sections like “Args:”, “Returns”, etc are kept intact. It is up to the consumer to remove these sections if they are present.

params: Vec<Param>

The parameters that this function takes. Docs for these parameters should generally be extracted from the main docstring’s details.

ret: Return

Details about what this function returns.

Implementations

Parses function documentation out of a docstring

Arguments
  • kind: The kind of docstring. This determines the formatting that is parsed.
  • params_producer: A function that takes a mapping of parameter names -> docstrings, and creates a vec of params. These are then returned in the main Function object.
  • return_type: The return type. This is pulled from typing info / directly from users, so it cannot be inferred generically.
  • raw_docstring: The raw docstring to be parsed and potentially modified, removing the sections detailing arguments and return values. The format is determined by kind.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Get an ARef pointing at this type.

Try and get an ARef pointing at this type. Returns an Err if the type Self is a RefCell which is already mutably borrowed. Read more

Return the underlying RefCell if Self is one, otherwise None.

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Convert between two equal types.

Convert between references to two equal types.

Convert between mutable references to two equal types.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.