deconstruct newtype rather than index tuple
This commit is contained in:
parent
5343c28701
commit
85537484d1
10
src/v0.rs
10
src/v0.rs
@ -517,12 +517,12 @@ pub struct BlockInfo{
|
||||
length:u32,
|
||||
}
|
||||
impl FileHeader{
|
||||
pub fn block_info(&self,block_id:BlockId)->Result<BlockInfo,Error>{
|
||||
if self.block_positions.len() as u32<=block_id.0{
|
||||
return Err(Error::InvalidBlockId(block_id));
|
||||
pub fn block_info(&self,BlockId(block_id):BlockId)->Result<BlockInfo,Error>{
|
||||
if self.block_positions.len() as u32<=block_id{
|
||||
return Err(Error::InvalidBlockId(BlockId(block_id)));
|
||||
}
|
||||
let start=self.block_positions[block_id.0 as usize].0;
|
||||
let end=self.block_positions[block_id.0 as usize+1].0;
|
||||
let BlockPosition(start)=self.block_positions[block_id as usize];
|
||||
let BlockPosition(end)=self.block_positions[block_id as usize+1];
|
||||
Ok(BlockInfo{start,length:end-start})
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user