MCPcopy Create free account
hub / github.com/Lokathor/tinyvec / write_str

Method write_str

src/arrayvec.rs:1698–1709  ·  view source on GitHub ↗
(&mut self, s: &str)

Source from the content-addressed store, hash-verified

1696#[cfg(feature = "experimental_write_impl")]
1697impl<A: Array<Item = u8>> core::fmt::Write for ArrayVec<A> {
1698 fn write_str(&mut self, s: &str) -> core::fmt::Result {
1699 let my_len = self.len();
1700 let str_len = s.as_bytes().len();
1701 if my_len + str_len <= A::CAPACITY {
1702 let remainder = &mut self.data.as_slice_mut()[my_len..];
1703 let target = &mut remainder[..str_len];
1704 target.copy_from_slice(s.as_bytes());
1705 Ok(())
1706 } else {
1707 Err(core::fmt::Error)
1708 }
1709 }
1710}
1711
1712// // // // // // // //

Callers 3

fmtMethod · 0.45
expectingMethod · 0.45
expectingMethod · 0.45

Calls 2

lenMethod · 0.45
as_slice_mutMethod · 0.45

Tested by

no test coverage detected