Start cleaning up warnings and dead code

This commit is contained in:
Erick Tryzelaar
2014-05-30 22:30:02 -07:00
parent a7b224702c
commit c6e503f8b3
2 changed files with 7 additions and 61 deletions
+3 -3
View File
@@ -509,7 +509,7 @@ impl<E, D: Deserializer<E>> Deserializable<E, D> for IgnoreTokens {
Str(_) | String(_) => { Str(_) | String(_) => {
let _: IgnoreTokens = try!(Deserializable::deserialize(d)); let _: IgnoreTokens = try!(Deserializable::deserialize(d));
} }
token => { return Err(d.syntax_error()); } _token => { return Err(d.syntax_error()); }
} }
} }
} }
@@ -590,7 +590,7 @@ impl GatherTokens {
StructStart(name, len) => { StructStart(name, len) => {
self.tokens.reserve_additional(len + 1); self.tokens.reserve_additional(len + 1);
self.tokens.push(StructStart(name, len)); self.tokens.push(StructStart(name, len));
self.gather_map(d) self.gather_struct(d)
} }
TupleStart(len) => { TupleStart(len) => {
self.tokens.reserve_additional(len + 1); self.tokens.reserve_additional(len + 1);
@@ -644,7 +644,7 @@ impl GatherTokens {
self.tokens.push(token); self.tokens.push(token);
try!(self.gather(d)) try!(self.gather(d))
} }
token => { return Err(d.syntax_error()); } _token => { return Err(d.syntax_error()); }
} }
} }
} }
+4 -58
View File
@@ -234,11 +234,8 @@ fn main() {
*/ */
use std::char; use std::char;
use std::f64;
use std::fmt; use std::fmt;
use std::io::MemWriter;
use std::io; use std::io;
use std::mem::swap;
use std::num; use std::num;
use std::str::ScalarValue; use std::str::ScalarValue;
use std::str; use std::str;
@@ -568,7 +565,6 @@ fn io_error_to_error(io: io::IoError) -> ParserError {
} }
pub type EncodeResult = io::IoResult<()>; pub type EncodeResult = io::IoResult<()>;
//pub type DecodeResult<T> = Result<T, DecoderError>;
fn escape_str(s: &str) -> String { fn escape_str(s: &str) -> String {
let mut escaped = String::from_str("\""); let mut escaped = String::from_str("\"");
@@ -2033,14 +2029,10 @@ pub fn from_iter<
// Make sure the whole stream has been consumed. // Make sure the whole stream has been consumed.
match parser.next() { match parser.next() {
Some(Ok(token)) => { Some(Ok(token)) => parser.error(TrailingCharacters),
fail!("internal json error, there should have not have been any tokens left"); Some(Err(err)) => Err(err),
} None => Ok(value),
Some(Err(err)) => { return Err(err); }
None => { }
} }
Ok(value)
} }
@@ -2052,31 +2044,6 @@ pub fn from_json<
de::Deserializable::deserialize(&mut d) de::Deserializable::deserialize(&mut d)
} }
/*
let contents = match rdr.read_to_end() {
Ok(c) => c,
Err(e) => return Err(io_error_to_error(e))
};
let s = match str::from_utf8(contents.as_slice()) {
Some(s) => s.to_string(),
None => return Err(SyntaxError(NotUtf8, 0, 0))
};
let mut builder = Builder::new(s.as_slice().chars());
builder.build()
*/
//}
/*
/// Decodes a json value from a string
pub fn from_str(s: &str) -> Result<Json, BuilderError> {
let mut builder = Builder::new(s.chars());
return builder.build();
}
*/
/// A structure to decode JSON to values in rust. /// A structure to decode JSON to values in rust.
pub struct Decoder { pub struct Decoder {
stack: Vec<Json>, stack: Vec<Json>,
@@ -2567,28 +2534,8 @@ impl fmt::Show for Json {
mod tests { mod tests {
extern crate test; extern crate test;
use self::test::Bencher; use self::test::Bencher;
/*
//use {Encodable, Decodable};
use super::{Encoder, Decoder, Error, Boolean, Number, List, String, Null,
PrettyEncoder, Object, Json, from_str, ParseError, ExpectedError,
MissingFieldError, UnknownVariantError, DecodeResult, DecoderError,
JsonEvent, Parser, StackElement,
ObjectStart, ObjectEnd, ListStart, ListEnd, BooleanValue, NumberValue, StringValue,
NullValue, SyntaxError, Key, Index, Stack,
InvalidSyntax, InvalidNumber, EOFWhileParsingObject, EOFWhileParsingList,
EOFWhileParsingValue, EOFWhileParsingString, KeyMustBeAString, ExpectedColon,
TrailingCharacters};
*/
use super::{ use super::{Json, String, List, Object};
Json,
Null,
Boolean,
Number,
String,
List,
Object,
};
use super::{Parser, ParserError, from_iter}; use super::{Parser, ParserError, from_iter};
use super::{JsonDeserializer, from_json, ToJson}; use super::{JsonDeserializer, from_json, ToJson};
use super::{ use super::{
@@ -2606,7 +2553,6 @@ mod tests {
use de; use de;
use std::fmt::Show; use std::fmt::Show;
use std::io;
use std::str; use std::str;
use collections::TreeMap; use collections::TreeMap;