#[non_exhaustive]pub struct Overload {
pub name: &'static str,
pub forms: &'static [OverloadForm],
}Expand description
A function name that stands for one node per argument type, as
vec_dot stands for vec_dot_f32 and vec_dot_f64
(polydat_grammar.md §18.1, T-Call-OverloadResolve).
A call to the name builds, among the forms every operand reaches by
its own type or through a lossless adapter, the one agreeing with
the most of the call’s wire types, position by position, and the
earliest such form when several agree with as many
(Overload::resolve). The assembler’s adapters then reach the
form’s other ports, as they reach any node’s. So vec_scale(v, 2)
over a vec_f64 builds the f64 form and widens the integer, and
vec_dot(a_f64, b_f32) builds the f64 form and widens b, rather
than narrowing an operand to reach a form. The first form is the one
the name meant before it had others, so operands that reach every
form equally build it, and a program that compiled against the name
still does. A node module submits one at
link time:
polydat::inventory::submit! {
Overload::new(
"vec_dot",
&[
OverloadForm::new(&[PortType::VecF32, PortType::VecF32], "vec_dot_f32"),
OverloadForm::new(&[PortType::VecF64, PortType::VecF64], "vec_dot_f64"),
],
)
}Every form takes the same parameters in the same order, so the name’s parameters are those of any form; only the wires’ types differ.
Built with Overload::new, a const fn, so a field added later
does not break the hosts that submit one.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.name: &'static strThe name programs call.
forms: &'static [OverloadForm]The forms the name resolves to, the default first.
Implementations§
Source§impl Overload
impl Overload
Sourcepub const fn new(name: &'static str, forms: &'static [OverloadForm]) -> Self
pub const fn new(name: &'static str, forms: &'static [OverloadForm]) -> Self
The overloaded name name of forms, the default first. A
node module submits it with inventory::submit!.
Sourcepub fn resolve(&self, wire_types: &[PortType]) -> &'static str
pub fn resolve(&self, wire_types: &[PortType]) -> &'static str
The function a call whose wires have wire_types builds.
Among the forms every wire reaches, by its own type or through
a lossless adapter (auto_adapter), the one agreeing with the
most of the wire types, the earliest among equals. So
vec_dot(a_f64, b_f32) builds the f64 form and widens b,
rather than narrowing a. When no form is reachable so, the
form agreeing with the most wire types, the earliest among
equals, and the assembler names the operand it cannot connect.
Sourcepub fn signature(&self) -> Option<&'static FuncSig>
pub fn signature(&self) -> Option<&'static FuncSig>
The signature of the first form, which a call to the name is
checked against before its wire types are known: every form
shares its parameters. Its name is the form’s, such as
vec_dot_f32, not the overload’s. None only when the first
form names no registered function.
Sourcepub fn category(&self) -> FuncCategory
pub fn category(&self) -> FuncCategory
The category the name is listed under: its first form’s, or
FuncCategory::Uncategorised when the first form names no
registered function.
Trait Implementations§
Auto Trait Implementations§
impl Forget for Overload
impl Freeze for Overload
impl Move for Overload
impl RefUnwindSafe for Overload
impl Send for Overload
impl Sync for Overload
impl Unpin for Overload
impl UnsafeUnpin for Overload
impl UnwindSafe for Overload
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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