fix Address::sub
This commit is contained in:
parent
764c4de6bf
commit
fbdbeb2842
|
@ -177,7 +177,7 @@ impl<S: Size> Sub for Address<S> {
|
|||
type Output = Address<S>;
|
||||
fn sub(self, rhs: Address<S>) -> Address<S> {
|
||||
Address::new(
|
||||
self.block + rhs.block,
|
||||
self.block - rhs.block,
|
||||
self.offset as isize - rhs.offset as isize,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -229,6 +229,11 @@ mod tests {
|
|||
#[test]
|
||||
fn file_len() {
|
||||
let file = RefCell::new(File::open("ext2.img").unwrap());
|
||||
assert_eq!(
|
||||
Address::<Size512>::from(2048_usize)
|
||||
- Address::<Size512>::from(1024_usize),
|
||||
Address::<Size512>::new(2, 0)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe {
|
||||
file.slice_unchecked(
|
||||
|
|
Reference in a new issue