Programming-Idioms

Implementation
Rust

Be concise.

Be useful.

All contributions dictatorially edited by webmasters to match personal tastes.

Please do not paste any copyright violating resource.

Please try to avoid dependencies to third-party libraries and frameworks.

Implementation edit is for fixing errors and enhancing with metadata.

Instead of changing the code of the snippet, consider creating another Rust implementation.

Other implementations
switch {
case c1:
	f1()
case c2:
	f2()
case c3:
	f3()
}
(cond (c1 (f1))
      (c2 (f2))
      (c3 (f3)))
case
  when c1
    f1
  when c2
    f2
  when c3
    f3
end
if ($c1)    { $f1 }
elsif ($c2) { $f2 }
elsif ($c3) { $f3 }
if      (c1) f1;
else if (c2) f2;
else if (c3) f3;
if c1 then f1 else if c2 then f2 else if c3 then f3;
f1 if c1 else f2 if c2 else f3 if c3 else None
if c1 then f1
else if c2 then f2
else f3
cond do
  c1 -> f1
  c2 -> f2
  c3 -> f3
end
c1 ? f1 : c2 ? f2 : f3
true match {
  case _ if c1 => f1()
  case _ if c2 => f2()
  case _ if c3 => f3()
}
match true {
    _ if c1 => f1(),
    _ if c2 => f2(),
    _ if c3 => f3(),
    _ => (),
}
if (c1) {
  f1()
} else if (c2) {
  f2()
} else if (c3) {
  f3()
}
switch (true) {
  case c1:
    f1();
    break;
  case c2:
    f2();
    break;
  case c3:
    f3();
    break;
}
if (c1) {
  f1();
} else if (c2) {
  f2();
} else if (c3) {
  f3();
}
if ($c1) {
  f1();
} else if ($c2) {
  f2();
} else if ($c3) {
  f3();
}
if (c1) {
   f1();
} else if (c2) {
   f2();
} else if (c3) { 
   f3();
}
if (c1)
{
    f1();
}
else if (c2)
{
    f2();
}
else if (c3)
{
    f3();
}
if c1:
    f1()
elif c2:
    f2()
elif c3:
    f3()
(cond (c1 (f1))
      (c2 (f2))
      (c3 (f3)))
if (c1) then
  call f1
else if (c2) then
  call f2
else if (c3) then
  call f3
end if
if (c1)
    f1();
else if (c2)
    f2();
else if (c3)
    f3();
if (c1)
{
    f1();
}
else if (c2)
{
    f2();
}
else if (c3)
{
    f3();
}
if
	C1 -> f1();
	C2 -> f2();
	C3 -> f3()
end.
(cond 
    c1 (f1)
    c2 (f2)
    c3 (f3))
IDENTIFICATION DIVISION.
PROGRAM-ID. condition.
PROCEDURE DIVISION.
    EVALUATE TRUE
	WHEN c1
	   PERFORM f1
	WHEN c2
	   PERFORM f2
	WHEN c3
	   PERFORM f3
    END-EVALUATE  
STOP RUN.
If c1 Then
    f1()
ElseIf c2 Then
    f2()
else c3 Then
    f3()
End If
if c1 then
    f1;
elsif c2 then
    f2;
elsif c3 then
    f3;
end if;
(c1 && (f1(), true))
 || (c2 && (f2(), true))
 || (c3 && (f3(), true));
if (c1)
{
    f1();
} 
else if (c2)
{
    f2();
}
else if (c3)
{
    f3();
}
			
when {
	c1 -> f1
	c2 -> f2
	c3 -> f3
}
if (c1) then f1()
elseif (c2) then f2()
elseif (c3) then f3()
end
if (c1) {
  f1;
} else if (c2) {
  f2;
} else if (c3) {
  f3;
}