pub struct Function {Show 14 fields
pub name: SmolStr,
pub args: Box<[(SmolStr, Option<DataType>)]>,
pub code: Rc<[Expr]>,
pub impls: Vec<FunctionImpl>,
pub is_recursive: Option<bool>,
pub returns_null: bool,
pub src_file: u16,
pub return_type_cache: Vec<(Box<[DataType]>, DataType)>,
pub direct_calls: Box<[SmolStr]>,
pub name_span: Span,
pub return_type: Option<(DataType, Span)>,
pub generics: Option<Box<FnGenerics>>,
pub captures: Box<[(SmolStr, DataType, Option<DataType>)]>,
pub entry_register: Option<u16>,
}Fields§
§name: SmolStr§args: Box<[(SmolStr, Option<DataType>)]>§code: Rc<[Expr]>§impls: Vec<FunctionImpl>§is_recursive: Option<bool>§returns_null: bool§src_file: u16§return_type_cache: Vec<(Box<[DataType]>, DataType)>Cache of return types from track_returns, keyed by Box
direct_calls: Box<[SmolStr]>§name_span: Span§return_type: Option<(DataType, Span)>The declared -> Type return annotation with the span it was written
at.
None leaves the return type inferred from the body. When present, the
inferred return type of every specialisation is checked against it.
generics: Option<Box<FnGenerics>>Set for a function that has type parameters of its own (fn first<T>)
or that came from an impl block on a generic type. None for an
ordinary function.
captures: Box<[(SmolStr, DataType, Option<DataType>)]>The variables an anonymous function reads from the scope it was written
in, with the type each had there, in the order the environment records
them. Empty for a declared function and for a closure that reads only
its own parameters, which is what keeps that closure lowering the way
it did before capture existed. The third member is the type the
variable’s let declared, which a write inside the body is held to.
entry_register: Option<u16>The register holding where this function’s body starts, for a function
that becomes a value. It is the first slot of every value built for the
function, and an indirect call jumps to what it holds. None for a
function no value is ever made of, which is every function a program
only calls by name.
Implementations§
Source§impl Function
impl Function
Sourcepub fn declared_params(&self) -> Option<Box<[DataType]>>
pub fn declared_params(&self) -> Option<Box<[DataType]>>
The parameter types a function that annotates every parameter declares,
which is what a call that cannot be seen passes it. None for a
function with a bare parameter or type parameters, whose types only a
call site settles.
Trait Implementations§
Auto Trait Implementations§
impl !Send for Function
impl !Sync for Function
impl Freeze for Function
impl RefUnwindSafe for Function
impl Unpin for Function
impl UnsafeUnpin for Function
impl UnwindSafe for Function
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
§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute] value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi [Quirk] value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);