Skip to content
This repository was archived by the owner on Sep 24, 2022. It is now read-only.
This repository was archived by the owner on Sep 24, 2022. It is now read-only.

Datetime with fractional times are not equal #179

@alanhdu

Description

@alanhdu

When I deserialize 06:00:00.0 and 06:00:00 into toml datetimes, they do not compare equal.

Even more confusingly, their Debug implementations are identical, so running

[test]
fn test_datetime_fraction() {
    let a = "key = 06:00:00.0";
    let b = "key = 06:00:00";


    let x: toml::Value = toml::from_str(a).unwrap();
    let y: toml::Value = toml::from_str(b).unwrap();

    assert_eq!(x.get("key").unwrap(), y.get("key").unwrap());
}

outputs

assertion failed: `(left == right)` (left: `Datetime(06:00:00)`, right: `Datetime(06:00:00)`)

I feel like either toml::datetime::Time's secfract field should be required (and default 0 when missing), or None should be equal to Some(0.0).

Found with rust-fuzz/targets#72

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions