mirror of
https://github.com/dlang/phobos.git
synced 2025-05-08 20:19:43 +03:00
Fix Issue 16135 - missing std.format import in std.algorithm.comparison
This commit is contained in:
parent
3c0b47ab51
commit
d1b59d3f2e
1 changed files with 18 additions and 0 deletions
|
@ -237,6 +237,7 @@ Note: $(D castSwitch) can only be used with object types.
|
||||||
auto castSwitch(choices...)(Object switchObject)
|
auto castSwitch(choices...)(Object switchObject)
|
||||||
{
|
{
|
||||||
import core.exception : SwitchError;
|
import core.exception : SwitchError;
|
||||||
|
import std.format : format;
|
||||||
|
|
||||||
// Check to see if all handlers return void.
|
// Check to see if all handlers return void.
|
||||||
enum areAllHandlersVoidResult = {
|
enum areAllHandlersVoidResult = {
|
||||||
|
@ -494,6 +495,23 @@ auto castSwitch(choices...)(Object switchObject)
|
||||||
)());
|
)());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@system unittest
|
||||||
|
{
|
||||||
|
interface I { }
|
||||||
|
class B : I { }
|
||||||
|
class C : I { }
|
||||||
|
|
||||||
|
assert((new B()).castSwitch!(
|
||||||
|
(B b) => "class B",
|
||||||
|
(I i) => "derived from I",
|
||||||
|
) == "class B");
|
||||||
|
|
||||||
|
assert((new C()).castSwitch!(
|
||||||
|
(B b) => "class B",
|
||||||
|
(I i) => "derived from I",
|
||||||
|
) == "derived from I");
|
||||||
|
}
|
||||||
|
|
||||||
/** Clamps a value into the given bounds.
|
/** Clamps a value into the given bounds.
|
||||||
|
|
||||||
This functions is equivalent to $(D max(lower, min(upper,val))).
|
This functions is equivalent to $(D max(lower, min(upper,val))).
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue