Skip to content
Snippets Groups Projects
Commit ebe96021 authored by Taiki Endo's avatar Taiki Endo Committed by Douman
Browse files

Fix build fail with serde feature (#293)

Verify no-std build and all features build
parent 97c13388
No related branches found
No related tags found
No related merge requests found
......@@ -29,9 +29,9 @@ jobs:
displayName: cargo ${{ parameters.cmd }}
# Run with each specified feature
- ${{ each feature in parameters.features.value }}:
- ${{ each feature in parameters.features }}:
- script: cargo ${{ parameters.cmd }} --features ${{ feature }}
displayName: cargo ${{ parameters.cmd }} --tests --features ${{ feature }}
displayName: cargo ${{ parameters.cmd }} --features ${{ feature }}
- ${{ if eq(parameters.cmd, 'test') }}:
- script: cargo doc --no-deps
......@@ -41,6 +41,10 @@ jobs:
- script: cargo check --benches
displayName: Check benchmarks
# Run with no default defaults
- script: cargo ${{ parameters.cmd }}
displayName: cargo ${{ parameters.cmd }} --no-default-features
# Run with all features
- script: cargo ${{ parameters.cmd }} --all-features
displayName: cargo ${{ parameters.cmd }} --all-features
# Run with no default features
- script: cargo check --no-default-features
displayName: cargo check --no-default-features
use alloc::string::String;
use alloc::vec::Vec;
use core::{cmp, fmt};
use serde::{Serialize, Serializer, Deserialize, Deserializer, de};
use super::{Bytes, BytesMut};
macro_rules! serde_impl {
($ty:ident, $visitor_ty:ident) => (
($ty:ident, $visitor_ty:ident, $from_slice:ident) => (
impl Serialize for $ty {
#[inline]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
......@@ -40,7 +42,7 @@ macro_rules! serde_impl {
fn visit_bytes<E>(self, v: &[u8]) -> Result<Self::Value, E>
where E: de::Error
{
Ok($ty::from(v))
Ok($ty::$from_slice(v))
}
#[inline]
......@@ -54,7 +56,7 @@ macro_rules! serde_impl {
fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
where E: de::Error
{
Ok($ty::from(v))
Ok($ty::$from_slice(v.as_bytes()))
}
#[inline]
......@@ -76,5 +78,5 @@ macro_rules! serde_impl {
);
}
serde_impl!(Bytes, BytesVisitor);
serde_impl!(BytesMut, BytesMutVisitor);
serde_impl!(Bytes, BytesVisitor, copy_from_slice);
serde_impl!(BytesMut, BytesMutVisitor, from);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment