Skip to content

Commit

Permalink
Remove save() and load().
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedcharles committed Jan 22, 2015
1 parent 27b3e14 commit 8a6a129
Showing 1 changed file with 1 addition and 26 deletions.
27 changes: 1 addition & 26 deletions src/libtest/lib.rs
Expand Up @@ -54,15 +54,14 @@ use self::OutputLocation::*;
use stats::Stats;
use getopts::{OptGroup, optflag, optopt};
use regex::Regex;
use serialize::{json, Decodable, Encodable};
use serialize::Encodable;
use term::Terminal;
use term::color::{Color, RED, YELLOW, GREEN, CYAN};

use std::any::Any;
use std::cmp;
use std::collections::BTreeMap;
use std::fmt;
use std::io::fs::PathExtensions;
use std::io::stdio::StdWriter;
use std::io::{File, ChanReader, ChanWriter};
use std::io;
Expand Down Expand Up @@ -990,30 +989,6 @@ impl MetricMap {
MetricMap(BTreeMap::new())
}

/// Load MetricDiff from a file.
///
/// # Panics
///
/// This function will panic if the path does not exist or the path does not
/// contain a valid metric map.
pub fn load(p: &Path) -> MetricMap {
assert!(p.exists());
let mut f = File::open(p).unwrap();
let value = json::from_reader(&mut f as &mut io::Reader).unwrap();
let mut decoder = json::Decoder::new(value);
MetricMap(match Decodable::decode(&mut decoder) {
Ok(t) => t,
Err(e) => panic!("failure decoding JSON: {:?}", e)
})
}

/// Write MetricDiff to a file.
pub fn save(&self, p: &Path) -> io::IoResult<()> {
let mut file = try!(File::create(p));
let MetricMap(ref map) = *self;
write!(&mut file, "{}", json::as_json(map))
}

/// Insert a named `value` (+/- `noise`) metric into the map. The value
/// must be non-negative. The `noise` indicates the uncertainty of the
/// metric, which doubles as the "noise range" of acceptable
Expand Down

0 comments on commit 8a6a129

Please sign in to comment.