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>;
|
type Output = Address<S>;
|
||||||
fn sub(self, rhs: Address<S>) -> Address<S> {
|
fn sub(self, rhs: Address<S>) -> Address<S> {
|
||||||
Address::new(
|
Address::new(
|
||||||
self.block + rhs.block,
|
self.block - rhs.block,
|
||||||
self.offset as isize - rhs.offset as isize,
|
self.offset as isize - rhs.offset as isize,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -229,6 +229,11 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn file_len() {
|
fn file_len() {
|
||||||
let file = RefCell::new(File::open("ext2.img").unwrap());
|
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!(
|
assert_eq!(
|
||||||
unsafe {
|
unsafe {
|
||||||
file.slice_unchecked(
|
file.slice_unchecked(
|
||||||
|
|
Reference in a new issue