Skip to content

Commit

Permalink
Generalize serialize implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
sosthene-nitrokey committed Jul 1, 2024
1 parent d7f7bf5 commit a9e9cc9
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/ser.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use core::hash::{BuildHasher, Hash};

use crate::{
binary_heap::Kind as BinaryHeapKind, linear_map::LinearMapInner, storage::Storage,
string::StringInner, vec::VecInner, BinaryHeap, Deque, HistoryBuffer, IndexMap, IndexSet,
binary_heap::Kind as BinaryHeapKind, deque::DequeInner, linear_map::LinearMapInner,
storage::Storage, string::StringInner, vec::VecInner, BinaryHeap, HistoryBuffer, IndexMap,
IndexSet,
};
use serde::ser::{Serialize, SerializeMap, SerializeSeq, Serializer};

Expand Down Expand Up @@ -58,15 +59,15 @@ where
}
}

impl<T, const N: usize> Serialize for Deque<T, N>
impl<T, S: Storage> Serialize for DequeInner<T, S>
where
T: Serialize,
{
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
fn serialize<SER>(&self, serializer: SER) -> Result<SER::Ok, SER::Error>
where
S: Serializer,
SER: Serializer,
{
let mut seq = serializer.serialize_seq(Some(self.len()))?;
let mut seq = serializer.serialize_seq(Some(self.storage_len()))?;
for element in self {
seq.serialize_element(element)?;
}
Expand Down

0 comments on commit a9e9cc9

Please sign in to comment.