Coverage / src/cli/json.rs 0.0%
0 of 20 lines run, 0 of 14 functions · run #21 on main · run missed
| 1 | | #![allow(dead_code)] |
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | | pub use oxy_core::repo::{json_array as arr, json_str as s}; |
| 6 | |
|
| 7 | 0× | pub fn obj<I: IntoIterator<Item = (&'static str, String)>>(pairs: I) -> String { |
| 8 | 0× | let inner: Vec<String> = pairs.into_iter().map(|(k, v)| format!("{}:{v}", s(k))).collect(); |
| 9 | 0× | format!("{{{}}}", inner.join(",")) |
| 10 | 0× | } |
| 11 | 0× | pub fn b(v: bool) -> String { |
| 12 | 0× | v.to_string() |
| 13 | 0× | } |
| 14 | 0× | pub fn n<T: std::fmt::Display>(v: T) -> String { |
| 15 | 0× | v.to_string() |
| 16 | 0× | } |
| 17 | 0× | pub fn opt<T>(v: Option<T>, f: impl Fn(T) -> String) -> String { |
| 18 | 0× | match v { |
| 19 | 0× | Some(x) => f(x), |
| 20 | 0× | None => "null".into(), |
| 21 | | } |
| 22 | 0× | } |
| 23 | 0× | pub fn hashes(v: &[oxy_core::hash::ChangeHash]) -> String { |
| 24 | 0× | arr(v.iter().map(|h| s(&h.to_hex()))) |
| 25 | 0× | } |