Skip to content

Commit

Permalink
Clippy cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
billallen256 committed Nov 1, 2024
1 parent 95ccfe4 commit 3a30b0c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
12 changes: 4 additions & 8 deletions src/bluejay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,15 @@ fn adjunct_lines(file: &File, header: &Header, lines: &mut Vec<String>) {
}

fn keyword_lines(header: &Header, lines: &mut Vec<String>) {
if header.keywords.len() == 0 {
if header.keywords.is_empty() {
lines.push(" \"keywords\": [],".to_string());
return;
}

lines.push(" \"keywords\": [".to_string());
let last_index = header.keywords.len() - 1;

for i in 0..header.keywords.len() {
let keyword = &header.keywords[i];

for (i, keyword) in header.keywords.iter().enumerate() {
if i == last_index {
lines.push(format!(" {{ \"name\": \"{}\", \"value\": \"{}\" }}", keyword.name, keyword.value));
} else {
Expand All @@ -126,17 +124,15 @@ fn ext_header_lines(file: &File, header: &Header, lines: &mut Vec<String>) {
},
};

if keywords.len() == 0 {
if keywords.is_empty() {
lines.push(" \"ext_header\": []".to_string());
return;
}

lines.push(" \"ext_header\": [".to_string());
let last_index = keywords.len() - 1;

for i in 0..keywords.len() {
let keyword = &keywords[i];

for (i, keyword) in keywords.iter().enumerate() {
if i == last_index {
lines.push(format!(" {{ \"name\": \"{}\", \"value\": {}, \"format\": \"{}\" }}", keyword.tag, keyword.value, keyword.value.format));
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ pub struct ExtKeywordValue {
impl fmt::Display for ExtKeywordValue {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.format {
'A' | 'S' | 'Z' => write!(f, "\"{}\"", from_utf8(&self.raw_value).unwrap().to_string()),
'A' | 'S' | 'Z' => write!(f, "\"{}\"", from_utf8(&self.raw_value).unwrap()),
'B' => write!(f, "{}", byte_to_i8(self.raw_value[0]).unwrap()),
'I' => write!(f, "{}", bytes_to_i16(&self.raw_value[0..1], self.endianness).unwrap()),
'L' => write!(f, "{}", bytes_to_i32(&self.raw_value[0..4], self.endianness).unwrap()),
Expand Down

0 comments on commit 3a30b0c

Please sign in to comment.