Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions clippy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
msrv = "1.36"
blacklisted-names = []
4 changes: 2 additions & 2 deletions src/de/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl<'de> Deserializer<'de> {
}

pub fn remainder(&self) -> Cow<'_, str> {
String::from_utf8_lossy(&self.bytes.bytes())
String::from_utf8_lossy(self.bytes.bytes())
}
}

Expand Down Expand Up @@ -315,7 +315,7 @@ impl<'de, 'a> de::Deserializer<'de> for &'a mut Deserializer<'de> {
let string = self.bytes.string()?;
let base64_str = match string {
ParsedStr::Allocated(ref s) => s.as_str(),
ParsedStr::Slice(ref s) => s,
ParsedStr::Slice(s) => s,
};
base64::decode(base64_str)
};
Expand Down
2 changes: 1 addition & 1 deletion src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ impl<'a> Bytes<'a> {
}

pub fn bytes(&self) -> &[u8] {
&self.bytes
self.bytes
}

pub fn char(&mut self) -> Result<char> {
Expand Down
7 changes: 4 additions & 3 deletions src/ser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,8 @@ impl<'a, W: io::Write> ser::Serializer for &'a mut Serializer<W> {

fn serialize_f32(self, v: f32) -> Result<()> {
write!(self.output, "{}", v)?;
// TODO: use f32::EPSILON when minimum supported rust version is 1.43
pub const EPSILON: f32 = 1.192_092_9e-7;
#[allow(clippy::excessive_precision)]
pub const EPSILON: f32 = 1.192_092_90e-07_f32;
if self.decimal_floats() && (v - v.floor()).abs() < EPSILON {
write!(self.output, ".0")?;
}
Expand All @@ -423,7 +423,8 @@ impl<'a, W: io::Write> ser::Serializer for &'a mut Serializer<W> {
fn serialize_f64(self, v: f64) -> Result<()> {
write!(self.output, "{}", v)?;
// TODO: use f64::EPSILON when minimum supported rust version is 1.43
pub const EPSILON: f64 = 2.220_446_049_250_313e-16;
#[allow(clippy::excessive_precision)]
pub const EPSILON: f64 = 2.220_446_049_250_313e-16_f64;
if self.decimal_floats() && (v - v.floor()).abs() < EPSILON {
write!(self.output, ".0")?;
}
Expand Down
4 changes: 2 additions & 2 deletions src/ser/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ fn test_map() {
map.insert((false, false), 123);

let s = to_string(&map).unwrap();
s.starts_with("{");
s.starts_with('{');
s.contains("(true,false):4");
s.contains("(false,false):123");
s.ends_with("}");
s.ends_with('}');
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions src/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ impl Map {
}

/// Returns `true` if `self.len() == 0`, `false` otherwise.
pub fn is_empty(&self) -> usize {
self.0.len()
pub fn is_empty(&self) -> bool {
self.0.len() == 0
}

/// Inserts a new element, returning the previous element with this `key` if
Expand Down
4 changes: 2 additions & 2 deletions tests/129_indexmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ tasks: {
Value::String("debug message".to_string())
);
assert_eq!(
*map.keys().skip(1).next().unwrap(),
*map.keys().nth(1).unwrap(),
Value::String("shell command".to_string())
);
}
Expand Down Expand Up @@ -65,7 +65,7 @@ tasks: {
Value::String("shell command".to_string())
);
assert_eq!(
*map.keys().skip(1).next().unwrap(),
*map.keys().nth(1).unwrap(),
Value::String("debug message".to_string())
);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/extensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const CONFIG_U_NT: &str = "

#[test]
fn unwrap_newtypes() {
let d: Struct = ron::de::from_str(&CONFIG_U_NT).expect("Failed to deserialize");
let d: Struct = ron::de::from_str(CONFIG_U_NT).expect("Failed to deserialize");

println!("unwrap_newtypes: {:#?}", d);
}
Expand Down Expand Up @@ -75,7 +75,7 @@ const CONFIG_I_S: &str = "

#[test]
fn implicit_some() {
let d: Struct = ron::de::from_str(&CONFIG_I_S).expect("Failed to deserialize");
let d: Struct = ron::de::from_str(CONFIG_I_S).expect("Failed to deserialize");

println!("implicit_some: {:#?}", d);
}
6 changes: 5 additions & 1 deletion tests/value.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use ron::value::{Map, Number, Value};
use serde::Serialize;
use std::f64;

#[test]
fn bool() {
Expand All @@ -23,7 +24,10 @@ fn map() {
#[test]
fn number() {
assert_eq!("42".parse(), Ok(Value::Number(Number::new(42))));
assert_eq!("3.1415".parse(), Ok(Value::Number(Number::new(3.1415f64))));
assert_eq!(
"3.141592653589793".parse(),
Ok(Value::Number(Number::new(f64::consts::PI)))
);
}

#[test]
Expand Down