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
use crate::{Stdout, Stderr}; impl ufmt::uWrite for Stdout { type Error = (); fn write_str(&mut self, text: &str) -> Result<(), Self::Error> { let result = unsafe { libc::write(1, text.as_ptr() as *const _, text.len() as _) }; if result < 0 { Err(()) } else { Ok(()) } } } impl ufmt::uWrite for Stderr { type Error = (); fn write_str(&mut self, text: &str) -> Result<(), Self::Error> { let result = unsafe { libc::write(2, text.as_ptr() as *const _, text.len() as _) }; if result < 0 { Err(()) } else { Ok(()) } } }