1
0

Syncing with codecrafters-io/languages

Created by https://github.com/codecrafters-io/languages
This commit is contained in:
Paul Kuruvilla 2021-10-24 17:06:07 +01:00
parent f3b575b186
commit 832b372beb

View File

@ -18,7 +18,7 @@ pub fn parse_record(stream: &[u8], column_count: usize) -> Result<Vec<Vec<u8>>>
// Parse each serial type as column into record and modify the offset // Parse each serial type as column into record and modify the offset
let mut record = vec![]; let mut record = vec![];
for serial_type in serial_types { for serial_type in serial_types {
let column = parse_column_value(&stream[offset..], serial_type as u8)?; let column = parse_column_value(&stream[offset..], serial_type as usize)?;
offset += column.len(); offset += column.len();
record.push(column); record.push(column);
} }
@ -26,7 +26,7 @@ pub fn parse_record(stream: &[u8], column_count: usize) -> Result<Vec<Vec<u8>>>
Ok(record) Ok(record)
} }
fn parse_column_value(stream: &[u8], serial_type: u8) -> Result<Vec<u8>> { fn parse_column_value(stream: &[u8], serial_type: usize) -> Result<Vec<u8>> {
let column_value = match serial_type { let column_value = match serial_type {
// 8 bit twos-complement integer // 8 bit twos-complement integer
1 => vec![stream[0]], 1 => vec![stream[0]],