From c5fae00c76dbd1af7ea7b6cde7a9281d82ee7cd2 Mon Sep 17 00:00:00 2001 From: Brad Dunbar Date: Sun, 3 Mar 2024 08:59:30 -0500 Subject: [PATCH] copy_to_bytes: Add panic section to docs (#676) Fixes #454. --- src/buf/buf_impl.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/buf/buf_impl.rs b/src/buf/buf_impl.rs index 9367eb2df..38ecf4bd9 100644 --- a/src/buf/buf_impl.rs +++ b/src/buf/buf_impl.rs @@ -1120,6 +1120,10 @@ pub trait Buf { /// let bytes = (&b"hello world"[..]).copy_to_bytes(5); /// assert_eq!(&bytes[..], &b"hello"[..]); /// ``` + /// + /// # Panics + /// + /// This function panics if `len > self.remaining()`. fn copy_to_bytes(&mut self, len: usize) -> crate::Bytes { use super::BufMut;