MCPcopy Create free account
hub / github.com/ashvardanian/StringZilla / write_str

Method write_str

rust/stringzilla.rs:802–813  ·  view source on GitHub ↗
(&mut self, s: &str)

Source from the content-addressed store, hash-verified

800
801impl<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
816pub type SmallCString = FixedCString<256>;

Callers 1

capabilities_from_enumFunction · 0.80

Calls 2

as_bytesMethod · 0.80
lenMethod · 0.80

Tested by

no test coverage detected