Skip to content

Consider making TimeZone: Send + Sync #345

@rnarubin

Description

@rnarubin

The TimeZone trait is not bound to Send or Sync, although most (all?) implementations would meet the requirements. This makes it difficult to work with generic DateTime<Tz> in multithreaded environments.

My particular use case is that I have an error enum for a date which might be out of certain bounds. In using the failure crate my errors must be Send + Sync, so this can't be generic over a DateTime<TimeZone> because the TimeZone trait doesn't meet the bounds. I'd either have to convert to a concrete timezone like Utc or use naive time.

#[derive(Debug, failure::Fail)]
pub enum DateOutOfBounds {
    #[fail(display = "Date is too early: {}", _0)]
    TooEarly(chrono::NaiveDateTime),
    #[fail(display = "Date is too late: {}", _0)]
    TooLate(chrono::NaiveDateTime),
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    API-incompatibleTracking changes that need incompatible API revisions

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions