diff options
| author | Brian Anderson <banderson@mozilla.com> | 2011-10-26 16:24:31 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2011-10-26 18:32:34 -0700 |
| commit | 4d669036f3264403f1663b14997a1e30db7b7e73 (patch) | |
| tree | 1d232920316333cbf8ccb287cf29f9756b60a3be /src/lib/ptr.rs | |
| parent | 1b75e5c315f00e6a10b1eca0a2f501107fd8063e (diff) | |
| download | rust-4d669036f3264403f1663b14997a1e30db7b7e73.tar.gz rust-4d669036f3264403f1663b14997a1e30db7b7e73.zip | |
Add more std documentation
Diffstat (limited to 'src/lib/ptr.rs')
| -rw-r--r-- | src/lib/ptr.rs | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/lib/ptr.rs b/src/lib/ptr.rs index 8d730732c3c..35644ab840b 100644 --- a/src/lib/ptr.rs +++ b/src/lib/ptr.rs @@ -1,13 +1,32 @@ -// Unsafe pointer utility functions. +/* +Module: ptr +Unsafe pointer utility functions +*/ native "rust-intrinsic" mod rusti { fn addr_of<T>(val: T) -> *mutable T; fn ptr_offset<T>(ptr: *T, count: uint) -> *T; } +/* +Function: addr_of + +Get an unsafe pointer to a value +*/ fn addr_of<T>(val: T) -> *mutable T { ret rusti::addr_of(val); } + +/* +Function: offset + +Calculate the offset from a pointer +*/ fn offset<T>(ptr: *T, count: uint) -> *T { ret rusti::ptr_offset(ptr, count); } +/* +Function: null + +Create an unsafe null pointer +*/ fn null<T>() -> *T { ret unsafe::reinterpret_cast(0u); } |
