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
14 changes: 6 additions & 8 deletions src/serde_json.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use core::str::Chars;
use core::{error::Error, time::Duration};
use core::{error::Error, fmt::Write, time::Duration};

use alloc::boxed::Box;
use alloc::collections::{BTreeMap, BTreeSet, LinkedList};
Expand Down Expand Up @@ -708,7 +708,7 @@ macro_rules! impl_ser_de_json_unsigned {
( $ ty: ident, $ max: expr) => {
impl SerJson for $ty {
fn ser_json(&self, _d: usize, s: &mut SerJsonState) {
s.out.push_str(&self.to_string());
_ = write!(s.out, "{self}");
}
}

Expand All @@ -726,7 +726,7 @@ macro_rules! impl_ser_de_json_signed {
( $ ty: ident, $ min: expr, $ max: expr) => {
impl SerJson for $ty {
fn ser_json(&self, _d: usize, s: &mut SerJsonState) {
s.out.push_str(&self.to_string());
_ = write!(s.out, "{self}");
}
}

Expand All @@ -745,7 +745,7 @@ macro_rules! impl_ser_de_json_float {
( $ ty: ident) => {
impl SerJson for $ty {
fn ser_json(&self, _d: usize, s: &mut SerJsonState) {
s.out.push_str(&format!("{self:?}"));
_ = write!(s.out, "{self:?}");
}
}

Expand Down Expand Up @@ -846,7 +846,6 @@ macro_rules! impl_ser_json_string {
'\r' => s.out += "\\r",
'\t' => s.out += "\\t",
_ if c.is_ascii_control() => {
use core::fmt::Write as _;
let _ = write!(s.out, "\\u{:04x}", c as u32);
}
'\\' => s.out += "\\\\",
Expand Down Expand Up @@ -1310,10 +1309,9 @@ where
impl SerJson for Duration {
fn ser_json(&self, _d: usize, s: &mut SerJsonState) {
s.out.push('{');
s.out.push_str(&format!("\"secs\":{}", self.as_secs()));
_ = write!(s.out, "\"secs\":{}", self.as_secs());
if self.subsec_nanos() > 0 {
s.out
.push_str(&format!(",\"nanos\":{}", self.subsec_nanos()));
_ = write!(s.out, ",\"nanos\":{}", self.subsec_nanos());
}
s.out.push('}');
}
Expand Down
13 changes: 6 additions & 7 deletions src/serde_ron.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use core::str::Chars;
use core::{error::Error, time::Duration};
use core::{error::Error, fmt::Write, time::Duration};

use alloc::boxed::Box;
use alloc::collections::{BTreeMap, BTreeSet, LinkedList};
Expand Down Expand Up @@ -710,7 +710,7 @@ macro_rules! impl_ser_de_ron_unsigned {
( $ ty: ident, $ max: expr) => {
impl SerRon for $ty {
fn ser_ron(&self, _d: usize, s: &mut SerRonState) {
s.out.push_str(&self.to_string());
_ = write!(s.out, "{self}");
}
}

Expand All @@ -729,7 +729,7 @@ macro_rules! impl_ser_de_ron_signed {
( $ ty: ident, $ min: expr, $ max: expr) => {
impl SerRon for $ty {
fn ser_ron(&self, _d: usize, s: &mut SerRonState) {
s.out.push_str(&self.to_string());
_ = write!(s.out, "{self}");
}
}

Expand All @@ -748,7 +748,7 @@ macro_rules! impl_ser_de_ron_float {
( $ ty: ident) => {
impl SerRon for $ty {
fn ser_ron(&self, _d: usize, s: &mut SerRonState) {
s.out.push_str(&format!("{self:?}"));
_ = write!(s.out, "{self:?}");
}
}

Expand Down Expand Up @@ -1307,10 +1307,9 @@ where
impl SerRon for Duration {
fn ser_ron(&self, _d: usize, s: &mut SerRonState) {
s.out.push('{');
s.out.push_str(&format!("\"secs\":{}", self.as_secs()));
_ = write!(s.out, "\"secs\":{}", self.as_secs());
if self.subsec_nanos() > 0 {
s.out
.push_str(&format!(",\"nanos\":{}", self.subsec_nanos()));
_ = write!(s.out, ",\"nanos\":{}", self.subsec_nanos());
}
s.out.push('}');
}
Expand Down
1 change: 0 additions & 1 deletion src/toml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ macro_rules! ident_chars {
'\u{41}'..='\u{5A}'
| '\u{61}'..='\u{7A}'
| '\u{30}'..='\u{39}'
| '\u{2D}'

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whats up with this one? Is this removal intentional?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, clippy told me that the pattern is unreachable because it is covered in an earlier branch, so I just removed it:

warning: unreachable pattern
   --> src/toml.rs:15:11
    |
 15 |         | '\u{2D}'
    |           ^^^^^^^^ no value can reach this
...
590 |             '-' => {
    |             --- matches all the relevant values
...
601 |             ident_chars!() => return self.parse_ident(i, num),
    |             -------------- in this macro invocation

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@not-fl3 Would it be possible for you to merge this MR already?

| '\u{5F}'
| '\u{B2}'
| '\u{B3}'
Expand Down
Loading