Crate bevy::ecs::ptr

source ·
Expand description

Bevy Ptr

License Crates.io Downloads Docs Discord

The bevy_ptr crate provides low-level abstractions for working with pointers in a more safe way than using rust’s raw pointers.

Rust has lifetimed and typed references (&'a T), unlifetimed and typed references (*const T), but no lifetimed but untyped references. bevy_ptr adds them, called Ptr<'a>, PtrMut<'a> and OwningPtr<'a>. These types are lifetime-checked so can never lead to problems like use-after-frees and must always point to valid data.

Structs

  • Used as a type argument to Ptr, PtrMut and OwningPtr to specify that the pointer is aligned.
  • Type-erased Box-like pointer to some unknown type chosen when constructing this type. Conceptually represents ownership of whatever data is being pointed to and so is responsible for calling its Drop impl. This pointer is not responsible for freeing the memory pointed to by this pointer as it may be pointing to an element in a Vec or to a local in a function etc.
  • Type-erased borrow of some unknown type chosen when constructing this type.
  • Type-erased mutable borrow of some unknown type chosen when constructing this type.
  • Conceptually equivalent to &'a [T] but with length information cut out for performance reasons
  • Used as a type argument to Ptr, PtrMut and OwningPtr to specify that the pointer is not aligned.

Traits

Functions