Skip to content
This repository has been archived by the owner on Dec 1, 2023. It is now read-only.

Generalize numeric primitive types on Json #63

Closed
frewsxcv opened this issue Feb 21, 2015 · 2 comments
Closed

Generalize numeric primitive types on Json #63

frewsxcv opened this issue Feb 21, 2015 · 2 comments

Comments

@frewsxcv
Copy link
Contributor

Instead of what we have now:

#[derive(Clone, PartialEq, PartialOrd, Debug)]
pub enum Json {
    I64(i64),
    U64(u64),
    F64(f64),
    String(string::String),
    Boolean(bool),
    Array(self::Array),
    Object(self::Object),
    Null,
}

do something like:

#[derive(Clone, PartialEq, PartialOrd, Debug)]
pub enum Json<I: SignedInt, U: UnsignedInt, F: Float> {
    Int(I),
    UInt(U),
    Float(F),
    String(string::String),
    Boolean(bool),
    Array(self::Array),
    Object(self::Object),
    Null,
}

Forgive me if this is a terrible idea. I was thinking about some of my large JSON datasets and it'd be nice to be able to control the precision for each numeric type.

@frewsxcv
Copy link
Contributor Author

This would definitely become more ergonomic when default parameters are implemented for generics. e.g.

pub enum Json<I=i64: SignedInt, U=u64: UnsignedInt, F=f64: Float> {
    ...
}

(assuming this is how these would work)

@alexcrichton
Copy link
Contributor

I'm going to close this now that this crate is deprecated in favor of serde. We're discontinuing feature development in rustc-serialize but will still continue to merge bug fixes if they arise.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants