Interface
Implementations of Type::API::Constraint::Inlinable MUST also implement Type::API::Constraint .
Implementations MUST provide the following methods:
-
$constraint->can_be_inlined
-
Returns a boolean indicating whether inlining support is available for this type constraint.
-
$constraint->inline_check($variable_name)
-
$variable_name
will be a string such as'$_'
or'$_[0]'
. Should return a string of code that may be evaluated to determine the pass/failure of the value in the given variable. The string MUST NOT includereturn
,goto
or other flow control keywords that would make it unsuitable for inlining into a larger function.
There is not currently any mechanism to request that the string of code in a particular programming language, nor a mechanism for the implementation to indicate what language it has generated. However, the implementations that have been investigated have returned Perl 5 code. Nevertheless, this is an area for further investigation.
Implementations
MAY
advertise that they support this interface by returning true for
$constraint->DOES("Type::API::Constraint::Inlinable")
.
See Also
Implementations
The following CPAN classes are known to implement Type::API::Constraint::Inlinable:
- Specio::Constraint::Simple (and several other classes in the Specio distribution)
- Type::Tiny (and its subclasses)
The following CPAN classes implement this interface with a minor difference; the
inline_check
method is called
_inline_check
instead. Tools wishing to make use of this interface should consider supporting this variation.
- Moose::Meta::TypeConstraint (and its subclasses)
- MooseX::Meta::TypeDecorator