1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//! Small utilities (Go `boxs` / `gpath` subset).
//!
//! These helpers are intentionally tiny; prefer them over ad-hoc one-liners in
//! application code when you want parity with the Go SDK naming.
//!
//! # Examples
//!
//! ```
//! use simplejrpc::util::{cond, join_ints};
//!
//! assert_eq!(cond(true, "a", "b"), "a");
//! assert_eq!(cond(false, "a", "b"), "b");
//! assert_eq!(join_ints(&[1, 2, 3]), "1,2,3");
//! assert_eq!(join_ints(&[]), "");
//! ```
/// Ternary-like helper (Go `boxs/cond.If`).
///
/// Returns `a` when `condition` is true, otherwise `b`.
///
/// # Examples
///
/// ```
/// use simplejrpc::util::cond;
/// assert_eq!(cond(2 > 1, 10, 20), 10);
/// assert_eq!(cond(2 < 1, 10, 20), 20);
/// ```
/// Join integers with commas (Go `slice.JoinIntSlice`).
///
/// # Examples
///
/// ```
/// use simplejrpc::util::join_ints;
/// assert_eq!(join_ints(&[7, 8]), "7,8");
/// assert_eq!(join_ints(&[42]), "42");
/// ```