Remove unwraps.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
e0bbb50b49
commit
c1d501cb3f
|
@ -192,18 +192,18 @@ fn write_sound_data_new(block: &BlockType) -> Result<Vec<u8>, Error> {
|
|||
}
|
||||
}
|
||||
|
||||
fn write_block(block: &BlockType) -> Vec<u8> {
|
||||
fn write_block(block: &BlockType) -> Result<Vec<u8>, Error> {
|
||||
match block {
|
||||
BlockType::Terminator => write_terminator(block).unwrap(),
|
||||
BlockType::SoundData { .. } => write_sound_data(block).unwrap(),
|
||||
BlockType::SoundDataContinuation { .. } => write_sound_data_continuation(block).unwrap(),
|
||||
BlockType::Silence { .. } => write_silence(block).unwrap(),
|
||||
BlockType::Marker { .. } => write_marker(block).unwrap(),
|
||||
BlockType::Text { .. } => write_text(block).unwrap(),
|
||||
BlockType::RepeatStart { .. } => write_repeat_start(block).unwrap(),
|
||||
BlockType::RepeatEnd => write_repeat_end(block).unwrap(),
|
||||
BlockType::ExtraInformation { .. } => write_extra_information(block).unwrap(),
|
||||
BlockType::SoundDataNew { .. } => write_sound_data_new(block).unwrap(),
|
||||
BlockType::Terminator => write_terminator(block),
|
||||
BlockType::SoundData { .. } => write_sound_data(block),
|
||||
BlockType::SoundDataContinuation { .. } => write_sound_data_continuation(block),
|
||||
BlockType::Silence { .. } => write_silence(block),
|
||||
BlockType::Marker { .. } => write_marker(block),
|
||||
BlockType::Text { .. } => write_text(block),
|
||||
BlockType::RepeatStart { .. } => write_repeat_start(block),
|
||||
BlockType::RepeatEnd => write_repeat_end(block),
|
||||
BlockType::ExtraInformation { .. } => write_extra_information(block),
|
||||
BlockType::SoundDataNew { .. } => write_sound_data_new(block),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -228,7 +228,14 @@ pub fn write_voc(voc: &Voc) -> Vec<u8> {
|
|||
let checksum = (!i16::from_le_bytes([voc.version.minor, voc.version.major]) + 0x1234) as u16;
|
||||
bytes.extend_from_slice(&checksum.to_le_bytes());
|
||||
for block in &voc.blocks {
|
||||
bytes.extend_from_slice(&write_block(block));
|
||||
match write_block(&block) {
|
||||
Ok(block_bytes) => {
|
||||
bytes.extend_from_slice(&block_bytes);
|
||||
},
|
||||
Err(error) => {
|
||||
eprintln!("Error writing block: {}", error);
|
||||
}
|
||||
}
|
||||
}
|
||||
bytes
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue