add panic and comment

This commit is contained in:
fakeshadow 2021-01-18 09:16:14 +08:00
parent 9a3ba6d04c
commit 0819cfbe7b
1 changed files with 8 additions and 0 deletions

View File

@ -343,9 +343,17 @@ impl ResponseHead {
} }
pub struct Message<T: Head> { pub struct Message<T: Head> {
// Rc here should not be cloned by anyone.
// It's used to reuse allocation of T and no shared ownership is allowed.
head: Rc<T>, head: Rc<T>,
} }
impl<T: Head> Clone for Message<T> {
fn clone(&self) -> Self {
panic!("Message<T> type should not be Clone.")
}
}
impl<T: Head> Message<T> { impl<T: Head> Message<T> {
/// Get new message from the pool of objects /// Get new message from the pool of objects
pub fn new() -> Self { pub fn new() -> Self {