Crate ptr_iter

source ·
Expand description

A crate with iterators to simplify working with pointers.

Constructing these iterators is unsafe, but once constructed the iteration itself is considered a safe operation.

The two iterators themselves will iterate forever. The constructor functions apply the correct iterator adapters to limit the iteration to stay within safe bounds.

Safety

  • You must always use the iterator before the pointer it’s based upon becomes invalidated. This is the same logic as constructing a slice from a raw pointer: If you use a pointer to build a safe type and then invalidate the source pointer, the safe type itself will become invalid too.
  • The iteration is done with the pointer add method, and so these iterators must only be constructed with pointers to valid allocations.

Structs