hel_time/
utils.rs

1pub trait Helper: std::fmt::Write {
2	#[inline(always)]
3	fn write_u8(&mut self, byte: u8) -> std::fmt::Result {
4		self.write_str(unsafe { std::str::from_utf8_unchecked(&[byte]) })
5	}
6}
7
8impl<T: std::fmt::Write> Helper for T {}
9
10// Took inspiration from `chrono` crate
11#[macro_export]
12macro_rules! write_hundreds {
13	($f: ident, $n: expr) => {
14		$f.write_u8(b'0' + ($n) as u8 / 10)?;
15		$f.write_u8(b'0' + ($n) as u8 % 10)?;
16	};
17}