mirror of
https://github.com/serde-rs/json.git
synced 2026-02-27 10:29:11 +00:00
Resolve branches_sharing_code clippy lint
error: all if blocks contain the same code at the start
--> src/ser.rs:319:9
|
319 | / if len == Some(0) {
320 | | tri!(self
321 | | .formatter
322 | | .begin_array(&mut self.writer)
323 | | .map_err(Error::io));
| |_____________________________________^
|
note: the lint level is defined here
--> src/lib.rs:304:9
|
304 | #![deny(clippy::all, clippy::pedantic)]
| ^^^^^^^^^^^
= note: `#[deny(clippy::branches_sharing_code)]` implied by `#[deny(clippy::all)]`
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#branches_sharing_code
help: consider moving the start statements out like this
|
319 | tri!(self
320 | .formatter
321 | .begin_array(&mut self.writer)
322 | .map_err(Error::io));
323 | if len == Some(0) {
|
error: all if blocks contain the same code at the start
--> src/ser.rs:388:9
|
388 | / if len == Some(0) {
389 | | tri!(self
390 | | .formatter
391 | | .begin_object(&mut self.writer)
392 | | .map_err(Error::io));
| |_____________________________________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#branches_sharing_code
help: consider moving the start statements out like this
|
388 | tri!(self
389 | .formatter
390 | .begin_object(&mut self.writer)
391 | .map_err(Error::io));
392 | if len == Some(0) {
|
This commit is contained in:
parent
d279a78a23
commit
7ca63e7d5a
24
src/ser.rs
24
src/ser.rs
@ -316,11 +316,11 @@ where
|
||||
|
||||
#[inline]
|
||||
fn serialize_seq(self, len: Option<usize>) -> Result<Self::SerializeSeq> {
|
||||
tri!(self
|
||||
.formatter
|
||||
.begin_array(&mut self.writer)
|
||||
.map_err(Error::io));
|
||||
if len == Some(0) {
|
||||
tri!(self
|
||||
.formatter
|
||||
.begin_array(&mut self.writer)
|
||||
.map_err(Error::io));
|
||||
tri!(self
|
||||
.formatter
|
||||
.end_array(&mut self.writer)
|
||||
@ -330,10 +330,6 @@ where
|
||||
state: State::Empty,
|
||||
})
|
||||
} else {
|
||||
tri!(self
|
||||
.formatter
|
||||
.begin_array(&mut self.writer)
|
||||
.map_err(Error::io));
|
||||
Ok(Compound::Map {
|
||||
ser: self,
|
||||
state: State::First,
|
||||
@ -385,11 +381,11 @@ where
|
||||
|
||||
#[inline]
|
||||
fn serialize_map(self, len: Option<usize>) -> Result<Self::SerializeMap> {
|
||||
tri!(self
|
||||
.formatter
|
||||
.begin_object(&mut self.writer)
|
||||
.map_err(Error::io));
|
||||
if len == Some(0) {
|
||||
tri!(self
|
||||
.formatter
|
||||
.begin_object(&mut self.writer)
|
||||
.map_err(Error::io));
|
||||
tri!(self
|
||||
.formatter
|
||||
.end_object(&mut self.writer)
|
||||
@ -399,10 +395,6 @@ where
|
||||
state: State::Empty,
|
||||
})
|
||||
} else {
|
||||
tri!(self
|
||||
.formatter
|
||||
.begin_object(&mut self.writer)
|
||||
.map_err(Error::io));
|
||||
Ok(Compound::Map {
|
||||
ser: self,
|
||||
state: State::First,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user