Merge pull request #4 from codecrafters-io/sync
Sync with languages repo
This commit is contained in:
commit
21da5ebc09
|
@ -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]],
|
||||||
|
|
Loading…
Reference in New Issue
Block a user