2 releases

0.1.1 Mar 8, 2023
0.1.0 Feb 21, 2023

#2767 in Rust patterns

Download history 57/week @ 2024-03-13 72/week @ 2024-03-20 71/week @ 2024-03-27 88/week @ 2024-04-03 67/week @ 2024-04-10 106/week @ 2024-04-17 73/week @ 2024-04-24 66/week @ 2024-05-01 61/week @ 2024-05-08 66/week @ 2024-05-15 75/week @ 2024-05-22 80/week @ 2024-05-29 55/week @ 2024-06-05 58/week @ 2024-06-12 56/week @ 2024-06-19 42/week @ 2024-06-26

219 downloads per month
Used in 3 crates (via zstring)

Zlib OR Apache-2.0 OR MIT

7KB
57 lines

Docs.rs

ptr_iter

Crate for iterating a pointer.


lib.rs:

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.

No runtime deps