Skip to content

Commit

Permalink
Remove the std_misc feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
erickt committed Apr 12, 2015
1 parent 8ba1e7a commit 7622255
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
19 changes: 16 additions & 3 deletions src/json/ser.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::{f32, f64};
use std::io;
use std::num::{Float, FpCategory};
use std::string::FromUtf8Error;
Expand Down Expand Up @@ -396,7 +395,14 @@ fn fmt_f32_or_null<W>(wr: &mut W, value: f32) -> io::Result<()>
{
match value.classify() {
FpCategory::Nan | FpCategory::Infinite => wr.write_all(b"null"),
_ => wr.write_all(f32::to_str_digits(value, 6).as_bytes()),
_ => {
let s = value.to_string();
try!(wr.write_all(s.as_bytes()));
if !s.contains('.') {
try!(wr.write_all(b".0"))
}
Ok(())
}
}
}

Expand All @@ -405,7 +411,14 @@ fn fmt_f64_or_null<W>(wr: &mut W, value: f64) -> io::Result<()>
{
match value.classify() {
FpCategory::Nan | FpCategory::Infinite => wr.write_all(b"null"),
_ => wr.write_all(f64::to_str_digits(value, 6).as_bytes()),
_ => {
let s = value.to_string();
try!(wr.write_all(s.as_bytes()));
if !s.contains('.') {
try!(wr.write_all(b".0"))
}
Ok(())
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//! leaving serde to perform roughly the same speed as a hand written serializer for a specific
//! type.

#![feature(collections, core, std_misc)]
#![feature(collections, core)]


pub use ser::{Serialize, Serializer};
Expand Down
7 changes: 2 additions & 5 deletions src/ser/impls.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::collections::hash_state::HashState;
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecMap};
use std::hash::Hash;
use std::path;
Expand Down Expand Up @@ -151,9 +150,8 @@ impl<T> Serialize for BTreeSet<T>
}
}

impl<T, H> Serialize for HashSet<T, H>
impl<T> Serialize for HashSet<T>
where T: Serialize + Eq + Hash,
H: HashState,
{
#[inline]
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error>
Expand Down Expand Up @@ -400,10 +398,9 @@ impl<K, V> Serialize for BTreeMap<K, V>
}
}

impl<K, V, H> Serialize for HashMap<K, V, H>
impl<K, V> Serialize for HashMap<K, V>
where K: Serialize + Eq + Hash,
V: Serialize,
H: HashState,
{
#[inline]
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error>
Expand Down
2 changes: 1 addition & 1 deletion tests/test_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ fn test_write_i64() {
#[test]
fn test_write_f64() {
let tests = &[
(3.0, "3"),
(3.0, "3.0"),
(3.1, "3.1"),
(-1.5, "-1.5"),
(0.5, "0.5"),
Expand Down

0 comments on commit 7622255

Please sign in to comment.