Skip to content

Feature req: Impl SerializeAs/DeserializeAs for std::ops::Range<Idx> #851

@takaomag

Description

@takaomag

Currently, the following struct can not be defined because std::ops::Range does not implement SerializeAs/DeserializeAs.

use std::ops::Range;
use chrono::{DateTime, Utc};

#[derive(Debug, serde::Serialize, serde::Deserialize)]
pub struct Test {
    #[serde(with = "serde_with::As::<Range<serde_with::TimestampNanoSeconds<i64, \
                    serde_with::formats::Strict>>>")]
    dt_range: Range<DateTime<Utc>>,
}

Like Option<T>, it would be helpful if Range<Idx>, RangeFrom<Idx>, RangeInclusive<Idx>, RangeTo<Idx> and RangeToInclusive<Idx> implement SerializeAs/DeserializeAs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions