pint_abi/
write.rs

1use essential_types::Word;
2
3/// A trait for writing essential `Word`s into buffers or streams.
4pub trait Write {
5    /// A type representing any error that might occur while writing words.
6    type Error: core::fmt::Debug + core::fmt::Display;
7    /// Write a single word into this writer, returning whether the write succeeded.
8    fn write_word(&mut self, w: Word) -> Result<(), Self::Error>;
9}
10
11impl<W: Write> Write for &'_ mut W {
12    type Error = W::Error;
13    fn write_word(&mut self, w: Word) -> Result<(), Self::Error> {
14        (*self).write_word(w)
15    }
16}
17
18impl Write for Vec<Word> {
19    type Error = core::convert::Infallible;
20    fn write_word(&mut self, w: Word) -> Result<(), Self::Error> {
21        self.push(w);
22        Ok(())
23    }
24}