(v: Val, s: &Spec)
| 170 | } |
| 171 | |
| 172 | fn format_char(v: Val, s: &Spec) -> Result<String, &'static str> { |
| 173 | if !v.is_int() { return Err("'c' format spec requires an integer"); } |
| 174 | let i = v.as_int(); |
| 175 | if !(0..=0x10FFFF).contains(&i) { return Err(C_RANGE_ERR); } |
| 176 | let ch = char::from_u32(i as u32).ok_or("'c' format spec arg not a valid char")?; |
| 177 | // 'c' is numeric for alignment: it defaults to right-align like ints. |
| 178 | Ok(pad_aligned(s, &ch.to_string(), 0)) |
| 179 | } |
| 180 | |
| 181 | fn format_int(v: Val, s: &Spec, heap: &HeapPool) -> Result<String, &'static str> { |
| 182 | let (neg, mag) = int_to_decimal_parts(v, heap)?; |
no test coverage detected