A function which takes the result type of a conversion as input, and yields the return type of the conversion block.
A function which takes the result type of a conversion as input, and yields the return type of the conversion block.
For example, if converting a String to a Boolean, this is a function
which takes Boolean
as input, and yields some type Result[Boolean]
(Boolean
for Convert.Valid, and Option[Boolean]
for Convert.Any).
An object containing an implicit conversion from Result[T]
to T
.
An object containing an implicit conversion from Result[T]
to T
.
The implicit conversion allows the automatic unwrapping of
Results, without explicitly calling unwrap.
USE THIS IMPLICIT CONVERSION AT YOUR OWN RISK
This implicit conversion can improve code readability; however, it should be used with care. As with all implicit conversions, it may be difficult to tell when it is applied by the compiler, leading to unexpected behavior which is difficult to debug.
Additionally, because unwrap MUST be called within a conversion block, this implicit conversion MUST be called within a conversion block as well. However, if imported in the wrong scope, the compiler may insert a call to this implicit conversion outside of any conversion block. Use this implicit conversion with care.
A wrapper object for an implicit reference to the enclosing Convert.
Performs a conversion.
Performs a conversion.
Conversion operations MUST take place within this block (a 'conversion block').
the type of the conversion's result
the result of the conversion, if it did not fail
Throws the specified exception.
Tests an expression, failing the conversion if false.
Tests an expression, failing the conversion if false. Analogous to Predef.require, except that it fails the conversion instead of always throwing an exception.
This method MUST be called within a conversion block from this Convert instance.
the expression to test
a String to include in the failure message
Tests an expression, failing the conversion if false.
Tests an expression, failing the conversion if false. Analogous to Predef.require, except that it fails the conversion instead of always throwing an exception.
This method MUST be called within a conversion block from this Convert instance.
the expression to test
Returns the result of another conversion.
Wraps a block of code which throws an exception, failing the conversion if the block throws an exception, and the exception matches the specified predicate.
Wraps a block of code which throws an exception, failing the conversion if the block throws an exception, and the exception matches the specified predicate.
This method MUST be called within a conversion block from this Convert instance.
the type of the result of body
a predicate to match certain exceptions to be wrapped
the block of code which may throw an exception
the result of body
, if it did not fail
Wraps a block of code which throws an exception, failing the conversion if the block throws an exception of the specified type.
Wraps a block of code which throws an exception, failing the conversion if the block throws an exception of the specified type.
This method MUST be called within a conversion block from this Convert instance.
the type of the exception
the type of the result of body
the block of code which may throw an exception
the result of body
, if it did not fail
A Convert which returns the result of a conversion as is, and throws an exception if the conversion fails.