Skip to content

Commit

Permalink
Use constants in match statement
Browse files Browse the repository at this point in the history
  • Loading branch information
sosthene-nitrokey committed Sep 13, 2024
1 parent fb94175 commit 184361f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pub const MAJOR_STR: u8 = 3;
pub const MAJOR_ARRAY: u8 = 4;
pub const MAJOR_MAP: u8 = 5;
pub const MAJOR_SIMPLE: u8 = 7;
pub const MAJOR_FLOAT: u8 = 7;

pub const SIMPLE_FALSE: u8 = 20;
pub const SIMPLE_TRUE: u8 = 21;
Expand Down
15 changes: 7 additions & 8 deletions src/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,18 +262,17 @@ impl<'de> Deserializer<'de> {
}

fn ignore(&mut self) -> Result<()> {
match self.peek_major()? {
0 => self.ignore_int(0)?,
1 => self.ignore_int(1)?,
2 => self.ignore_bytes(2)?,
3 => self.ignore_bytes(3)?,
4 => self.ignore_array(4, 1)?,
5 => self.ignore_array(5, 2)?,
let major = self.peek_major()?;
match major {
MAJOR_POSINT | MAJOR_NEGINT => self.ignore_int(major)?,
MAJOR_BYTES | MAJOR_STR => self.ignore_bytes(major)?,
MAJOR_ARRAY => self.ignore_array(MAJOR_ARRAY, 1)?,
MAJOR_MAP => self.ignore_array(MAJOR_MAP, 2)?,
6 => {
self.ignore_int(6)?;
self.ignore()?;
}
7 => self.ignore_float()?,
MAJOR_FLOAT => self.ignore_float()?,
_ => return Err(Error::DeserializeBadMajor),
}
Ok(())
Expand Down

0 comments on commit 184361f

Please sign in to comment.