Skip to content

Commit

Permalink
Cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Bartlett authored and Licenser committed Oct 22, 2024
1 parent 2b0a838 commit de7b6c3
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 24 deletions.
24 changes: 18 additions & 6 deletions src/numberparse/correct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ mod test {
use crate::value::owned::to_value;
use crate::value::owned::Value;
use crate::value::owned::Value::Static;
use value_trait::StaticNode::{self,I64,U64};
use value_trait::StaticNode::{self, I64, U64};

fn to_value_from_str(buf: &str) -> Result<Value, Error> {
let mut val = String::from(buf);
Expand All @@ -421,7 +421,10 @@ mod test {
to_value_from_str("-12345678901234.56789012")?,
Static(StaticNode::from(-12_345_678_901_234.568))
);
assert_eq!(to_value_from_str("0.4e-001")?, Static(StaticNode::from(0.04)));
assert_eq!(
to_value_from_str("0.4e-001")?,
Static(StaticNode::from(0.04))
);
assert_eq!(
to_value_from_str("0.123456789e-12")?,
Static(StaticNode::from(1.234_567_89e-13))
Expand All @@ -434,9 +437,12 @@ mod test {
assert_eq!(
to_value_from_str("0.0000000000000000000000000000000000000000000000000123e50")
.expect("1.23"),
Static(StaticNode::from(1.23))
Static(StaticNode::from(1.23))
);
assert_eq!(
to_value_from_str("0.6").expect("0.6"),
Static(StaticNode::from(0.6))
);
assert_eq!(to_value_from_str("0.6").expect("0.6"), Static(StaticNode::from(0.6)));
Ok(())
}

Expand Down Expand Up @@ -536,9 +542,15 @@ mod test {
#[test]
fn zero_float() -> Result<(), crate::Error> {
assert_eq!(to_value_from_str("0e1")?, Static(StaticNode::from(0.0)));
assert_eq!(to_value_from_str("0.00e-00")?, Static(StaticNode::from(0.0)));
assert_eq!(
to_value_from_str("0.00e-00")?,
Static(StaticNode::from(0.0))
);
assert_eq!(to_value_from_str("0e-1")?, Static(StaticNode::from(-0.0)));
assert_eq!(to_value_from_str("-0.00e-00")?, Static(StaticNode::from(-0.0)));
assert_eq!(
to_value_from_str("-0.00e-00")?,
Static(StaticNode::from(-0.0))
);
Ok(())
}

Expand Down
4 changes: 2 additions & 2 deletions src/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ pub unsafe fn from_str<'a, T>(s: &'a mut str) -> Result<T>
where
T: Deserialize<'a>,
{
let mut deserializer = stry!(Deserializer::from_slice(unsafe{s.as_bytes_mut()}));
let mut deserializer = stry!(Deserializer::from_slice(unsafe { s.as_bytes_mut() }));

T::deserialize(&mut deserializer)
}
Expand Down Expand Up @@ -126,7 +126,7 @@ where
T: Deserialize<'a>,
{
let mut deserializer = stry!(Deserializer::from_slice_with_buffers(
unsafe{s.as_bytes_mut()},
unsafe { s.as_bytes_mut() },
buffers
));

Expand Down
2 changes: 1 addition & 1 deletion src/value/borrowed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ impl<'tape, 'de> BorrowSliceDeserializer<'tape, 'de> {
}
#[cfg_attr(not(feature = "no-inline"), inline)]
pub unsafe fn next_(&mut self) -> Node<'de> {
let r = unsafe{*self.tape.get_kinda_unchecked(self.idx)};
let r = unsafe { *self.tape.get_kinda_unchecked(self.idx) };
self.idx += 1;
r
}
Expand Down
33 changes: 18 additions & 15 deletions tests/ordered_float.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
// A small test to show that ordered-float does allow us to "do stuff" Eq-wise
// with values when we opt for an Eq-compatible representation of floats.
// Easiest way is simply to construct a type that derives Eq and include
// simd Values in it, construct it, and compare it! This won't even compile
// simd Values in it, construct it, and compare it! This won't even compile
// if we have got it wrong
#[cfg(feature = "ordered-float")]
use simd_json::{BorrowedValue, OwnedValue};

#[cfg(feature = "ordered-float")]
#[test]
fn test_values_as_hashmap_keys() {
#[derive(Eq, PartialEq, Debug)]
struct AnEqType {
owned_value: OwnedValue,
borrowed_value: BorrowedValue<'static>
}
let an_eq_type = AnEqType {
owned_value: OwnedValue::from("an-owned-value"),
borrowed_value: BorrowedValue::from("a-borrowed-value")
};
#[derive(Eq, PartialEq, Debug)]
struct AnEqType {
owned_value: OwnedValue,
borrowed_value: BorrowedValue<'static>,
}
let an_eq_type = AnEqType {
owned_value: OwnedValue::from("an-owned-value"),
borrowed_value: BorrowedValue::from("a-borrowed-value"),
};

assert_eq!(an_eq_type, AnEqType {
owned_value: OwnedValue::from("an-owned-value"),
borrowed_value: BorrowedValue::from("a-borrowed-value")
});
}
assert_eq!(
an_eq_type,
AnEqType {
owned_value: OwnedValue::from("an-owned-value"),
borrowed_value: BorrowedValue::from("a-borrowed-value")
}
);
}

0 comments on commit de7b6c3

Please sign in to comment.