1use std::io;
3
4pub trait WriteBytesExt<T> {
6 fn write_le(&mut self, n: T) -> io::Result<()>;
8
9 }
16
17impl<W: io::Write + ?Sized> WriteBytesExt<u8> for W {
18 #[inline(always)]
19 fn write_le(&mut self, n: u8) -> io::Result<()> {
20 self.write_all(&[n])
21 }
22}
23
24impl<W: io::Write + ?Sized> WriteBytesExt<u16> for W {
25 #[inline]
26 fn write_le(&mut self, n: u16) -> io::Result<()> {
27 self.write_all(&n.to_le_bytes())
28 }
29}
30
31impl<W: io::Write + ?Sized> WriteBytesExt<u32> for W {
32 #[inline]
33 fn write_le(&mut self, n: u32) -> io::Result<()> {
34 self.write_all(&n.to_le_bytes())
35 }
36}
37
38impl<W: io::Write + ?Sized> WriteBytesExt<u64> for W {
39 #[inline]
40 fn write_le(&mut self, n: u64) -> io::Result<()> {
41 self.write_all(&n.to_le_bytes())
42 }
43}