From 85537484d17887e4a709ab3f78ca0268530aa262 Mon Sep 17 00:00:00 2001 From: Quaternions <krakow20@gmail.com> Date: Thu, 20 Mar 2025 19:55:01 -0700 Subject: [PATCH] deconstruct newtype rather than index tuple --- src/v0.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/v0.rs b/src/v0.rs index 6871e98..d9e50c0 100644 --- a/src/v0.rs +++ b/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}) } }