2 releases

0.1.1 Mar 8, 2023
0.1.0 Feb 21, 2023

#2843 in Rust patterns

Download history 55/week @ 2023-12-18 32/week @ 2023-12-25 30/week @ 2024-01-01 39/week @ 2024-01-08 58/week @ 2024-01-15 47/week @ 2024-01-22 39/week @ 2024-01-29 51/week @ 2024-02-05 60/week @ 2024-02-12 73/week @ 2024-02-19 186/week @ 2024-02-26 68/week @ 2024-03-04 58/week @ 2024-03-11 62/week @ 2024-03-18 70/week @ 2024-03-25 103/week @ 2024-04-01

304 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