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
//! String-related utilities.
//!
//! Serialization function takes `&mut [u8]` or similar types rather than
//! `&mut W where W: std::io::Write`, because `core` does not have an alternative
//! of `std::io::Write`, and `core::fmt::Write` is not implemented for `&mut [u8]`.
/// Writes 0-padded 4 digits string.
///
/// It is guaranteed that this does not panic and `buf` is filled with ASCII digits.
///
/// # Failures
///
/// Note that this function writes meaning less content for integer which is not
/// representable with 4 digits.
/// This is safe in a sense that this never cause UB for any integer input, but
/// callers should ensure that the integer value is less than 10000.
pub
/// Writes 0-padded 2 digits string.
///
/// It is guaranteed that this does not panic and `buf` is filled with ASCII digits.
///
/// # Failures
///
/// Note that this function writes meaning less content for integer which is not
/// representable with 4 digits.
/// This is safe in a sense that this never cause UB for any integer input, but
/// callers should ensure that the integer value is less than 10000.
pub