Skip to content

Commit 9aa6e57

Browse files
jwisenikomatsakis
authored andcommitted
ptr: Add mut_offset, to be able to calculate an offset on mutable pointers.
1 parent 020d8f1 commit 9aa6e57

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/lib/ptr.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ fn offset<T>(ptr: *T, count: uint) -> *T {
3434
ret rusti::ptr_offset(ptr, count);
3535
}
3636

37+
/*
38+
Function: mut_offset
39+
40+
Calculate the offset from a mutable pointer
41+
*/
42+
fn mut_offset<T>(ptr: *mutable T, count: uint) -> *mutable T {
43+
ret rusti::ptr_offset(ptr as *T, count) as *mutable T;
44+
}
45+
46+
3747
/*
3848
Function: null
3949

0 commit comments

Comments
 (0)