Skip to content

Commit

Permalink
add impl Default
Browse files Browse the repository at this point in the history
  • Loading branch information
TimLuq committed Jul 11, 2024
1 parent 9115fcd commit 1d8f656
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/byte_chunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,13 @@ impl ByteChunk {
Self::slice(self, start, end);
}
}

impl Default for ByteChunk {
#[inline]
fn default() -> Self {
ByteChunk {
len: 0,
data: [0; 12],
}
}
}
7 changes: 7 additions & 0 deletions src/bytedata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,3 +605,10 @@ impl<'a> core::borrow::Borrow<[u8]> for ByteData<'a> {
self.as_slice()
}
}

impl<'a> Default for ByteData<'a> {
#[inline]
fn default() -> Self {
ByteData::empty()
}
}
9 changes: 8 additions & 1 deletion src/queue/byte_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::queue::ChunkIter;

/// A queue of byte chunks.
#[cfg_attr(docsrs, doc(cfg(feature = "queue")))]
#[derive(Clone, Default)]
#[derive(Clone)]
#[allow(private_interfaces)]
pub struct ByteQueue<'a> {
pub(crate) queue: LinkedRoot<'a>,
Expand Down Expand Up @@ -906,3 +906,10 @@ impl core::fmt::UpperHex for ByteQueue<'_> {
Ok(())
}
}

impl<'a> Default for ByteQueue<'a> {
#[inline]
fn default() -> Self {
ByteQueue::new()
}
}
9 changes: 9 additions & 0 deletions src/queue/string_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,15 @@ impl core::fmt::Debug for crate::StringQueue<'_> {
}
}

impl<'a> Default for crate::StringQueue<'a> {
#[inline]
fn default() -> Self {
Self {
queue: crate::ByteQueue::new(),
}
}
}

impl Eq for crate::StringQueue<'_> {}
impl<'a, 'b> PartialEq<crate::StringQueue<'b>> for crate::StringQueue<'a> {
#[inline]
Expand Down
6 changes: 6 additions & 0 deletions src/shared_bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,3 +460,9 @@ impl core::fmt::UpperHex for SharedBytes {
Ok(())
}
}

impl Default for SharedBytes {
fn default() -> Self {
Self::EMPTY
}
}
7 changes: 7 additions & 0 deletions src/stringdata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -617,3 +617,10 @@ impl<'a> core::borrow::Borrow<str> for StringData<'a> {
self.as_str()
}
}

impl<'a> Default for StringData<'a> {
#[inline]
fn default() -> Self {
StringData::empty()
}
}

0 comments on commit 1d8f656

Please sign in to comment.