FIX: Fix serde feature for const gen

This commit is contained in:
bluss
2021-03-23 17:49:11 +01:00
parent c9b095f263
commit 6daae9ae68
5 changed files with 22 additions and 25 deletions
+3 -3
View File
@@ -533,10 +533,10 @@ impl<'de, const CAP: usize> Deserialize<'de> for ArrayString<CAP>
use serde::de::{self, Visitor};
use std::marker::PhantomData;
struct ArrayStringVisitor<const CAP: usize>(PhantomData([u8; CAP]));
struct ArrayStringVisitor<const CAP: usize>(PhantomData<[u8; CAP]>);
impl<'de, const CAP: usize> Visitor<'de> for ArrayStringVisitor {
type Value = ArrayString;
impl<'de, const CAP: usize> Visitor<'de> for ArrayStringVisitor<CAP> {
type Value = ArrayString<CAP>;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
write!(formatter, "a string no more than {} bytes long", CAP)
+3 -3
View File
@@ -1141,17 +1141,17 @@ impl<'de, T: Deserialize<'de>, const CAP: usize> Deserialize<'de> for ArrayVec<T
type Value = ArrayVec<T, CAP>;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
write!(formatter, "an array with no more than {} items", A::CAPACITY)
write!(formatter, "an array with no more than {} items", CAP)
}
fn visit_seq<SA>(self, mut seq: SA) -> Result<Self::Value, SA::Error>
where SA: SeqAccess<'de>,
{
let mut values = ArrayVec::<A>::new();
let mut values = ArrayVec::<T, CAP>::new();
while let Some(value) = seq.next_element()? {
if let Err(_) = values.try_push(value) {
return Err(SA::Error::invalid_length(A::CAPACITY + 1, &self));
return Err(SA::Error::invalid_length(CAP + 1, &self));
}
}
-3
View File
@@ -34,9 +34,6 @@ extern crate serde;
#[cfg(not(feature="std"))]
extern crate core as std;
#[cfg(feature="serde")]
use serde::{Serialize, Deserialize, Serializer, Deserializer};
mod array;
mod arrayvec_impl;
mod arrayvec;