(&mut self, s: &str)
| 800 | |
| 801 | impl<const N: usize> Write for FixedCString<N> { |
| 802 | fn write_str(&mut self, s: &str) -> fmt::Result { |
| 803 | let bytes = s.as_bytes(); |
| 804 | // Ensure we have room for the new bytes and a NUL terminator. |
| 805 | if self.len + bytes.len() >= N { |
| 806 | return Err(fmt::Error); |
| 807 | } |
| 808 | self.buf[self.len..self.len + bytes.len()].copy_from_slice(bytes); |
| 809 | self.len += bytes.len(); |
| 810 | // Always set a null terminator. |
| 811 | self.buf[self.len] = 0; |
| 812 | Ok(()) |
| 813 | } |
| 814 | } |
| 815 | |
| 816 | pub type SmallCString = FixedCString<256>; |
no test coverage detected