Skip to content

Commit

Permalink
Implement IoBuf for Rc<T> where T: IoBuf
Browse files Browse the repository at this point in the history
  • Loading branch information
redbaron committed Feb 20, 2023
1 parent 575d864 commit 09447ec
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/buf/io_buf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,20 @@ unsafe impl IoBuf for &'static str {
}
}

unsafe impl<T:IoBuf> IoBuf for std::rc::Rc<T> {
fn stable_ptr(&self) -> *const u8 {
self.as_ref().stable_ptr()
}

fn bytes_init(&self) -> usize {
self.as_ref().bytes_init()
}

fn bytes_total(&self) -> usize {
self.as_ref().bytes_total()
}
}

#[cfg(feature = "bytes")]
unsafe impl IoBuf for bytes::Bytes {
fn stable_ptr(&self) -> *const u8 {
Expand Down

0 comments on commit 09447ec

Please sign in to comment.