Struct AnyVec

Source
pub struct AnyVec { /* private fields */ }
Expand description

A type-erased vector containing values of the same type.

This vector would be useful when you need to hold vectors of heterogeneous types in a single variable. Instead, this vector has methods that looks quite dirty and not easy to use. Most methods are unsafe because they take or return pointer instead of concrete type.

Implementations§

Source§

impl AnyVec

Source

pub fn new(tinfo: TypeInfo) -> Self

Creates a new empty vector.

§Examples
use my_ecs::{tinfo, ds::AnyVec};

let v = AnyVec::new(tinfo!(i32));
Source

pub const fn type_info(&self) -> &TypeInfo

Returns TypeInfo of the item.

§Examples
use my_ecs::{tinfo, ds::AnyVec};

let v = AnyVec::new(tinfo!(i32));
assert_eq!(v.type_info(), &tinfo!(i32));
Source

pub const fn type_id(&self) -> TypeId

Returns TypeId of the item.

§Examples
use my_ecs::{tinfo, ds::AnyVec};

let v = AnyVec::new(tinfo!(i32));
assert_eq!(v.type_id(), std::any::TypeId::of::<i32>());
Source

pub const fn type_name(&self) -> &'static str

Returns name of the item based on type_name.

§Examples
use my_ecs::{tinfo, ds::AnyVec};

let v = AnyVec::new(tinfo!(i32));
println!("{}", v.type_name());
Source

pub const fn item_size(&self) -> usize

Returns size in bytes of the item.

§Examples
use my_ecs::{tinfo, ds::AnyVec};

let v = AnyVec::new(tinfo!(i32));
assert_eq!(v.item_size(), std::mem::size_of::<i32>());
Source

pub const fn is_zst(&self) -> bool

Returns whether the item is zero-sized type or not.

§Examples
use my_ecs::{tinfo, ds::AnyVec};

let v = AnyVec::new(tinfo!(i32));
assert!(!v.is_zst());
let v = AnyVec::new(tinfo!(()));
assert!(v.is_zst());
Source

pub const fn align(&self) -> usize

Returns alignment in bytes of the item.

§Examples
use my_ecs::{tinfo, ds::AnyVec};

let v = AnyVec::new(tinfo!(i32));
assert_eq!(v.align(), std::mem::align_of::<i32>());
Source

pub const fn fn_drop(&self) -> FnDropRaw

Returns raw drop function pointer.

Source

pub const fn fn_clone(&self) -> FnCloneRaw

Returns raw clone function pointer.

Source

pub const fn is_clone(&self) -> bool

Returns whether the item is Clone or not.

§Examples
use my_ecs::{tinfo, ds::AnyVec};

let v = AnyVec::new(tinfo!(i32));
assert!(v.is_clone());

struct S;
let v = AnyVec::new(tinfo!(S));
assert!(!v.is_clone());
Source

pub const fn is_send(&self) -> bool

Returns whether the item is Send or not.

§Examples
use my_ecs::{tinfo, ds::AnyVec};

let v = AnyVec::new(tinfo!(i32));
assert!(v.is_send());
// let v = AnyVec::new(tinfo!(*const u8)); // Disallowed for now.
Source

pub const fn is_sync(&self) -> bool

Returns whether the item is Sync or not.

§Examples
use my_ecs::{tinfo, ds::AnyVec};

let v = AnyVec::new(tinfo!(i32));
assert!(v.is_sync());
// let v = AnyVec::new(tinfo!(*const u8)); // Disallowed for now.
Source

pub fn is_type_of<T: 'static>(&self) -> bool

Returns true if the given TypeId is the same as item of the vector.

§Examples
use my_ecs::{tinfo, ds::AnyVec};

let v = AnyVec::new(tinfo!(i32));
assert!(v.is_type_of::<i32>());
Source

pub const fn len(&self) -> usize

Returns number of item.

§Examples
use my_ecs::{tinfo, ds::AnyVec};

let mut v = AnyVec::new(tinfo!(i32));
unsafe { v.push(0_i32) };
assert_eq!(v.len(), 1);
Source

pub const fn is_empty(&self) -> bool

Returns true if the vector is empty.

§Examples
use my_ecs::{tinfo, ds::AnyVec};

let v = AnyVec::new(tinfo!(i32));
assert!(v.is_empty());
Source

pub const fn capacity(&self) -> usize

Returns capacity in bytes of the vector.

§Examples
use my_ecs::{tinfo, ds::AnyVec};

let mut v = AnyVec::new(tinfo!(i32));
v.reserve(10);
assert!(v.capacity() >= 10);
Source

pub fn iter_of<T: 'static>(&self) -> Iter<'_, T>

Returns iterator visiting all items.

§Panics

Panics if the given type is not the same as the vector contains.

§Examples
use my_ecs::{tinfo, ds::AnyVec};

let mut v = AnyVec::new(tinfo!(i32));
unsafe {
    v.push(0_i32);
    v.push(1_i32);
}
for x in v.iter_of::<i32>() {
    println!("{x}");
}
Source

pub fn iter_mut_of<T: 'static>(&mut self) -> IterMut<'_, T>

Returns mutable iterator visiting all items.

§Panics

Panics if the given type is not the same as the vector contains.

§Examples
use my_ecs::{tinfo, ds::AnyVec};

let mut v = AnyVec::new(tinfo!(i32));
unsafe {
    v.push(0_i32);
    v.push(1_i32);
}
for x in v.iter_mut_of::<i32>() {
    *x += 10;
}
Source

pub fn par_iter_of<T: Send + Sync + 'static>(&self) -> ParIter<'_, T>

Returns parallel iterator visiting all items.

Parallel iterator implements rayon’s parallel iterator traits, so that it can be split into multiple CPU cores then consumed at the same time.

§Panics

Panics if the given type is not the same as the vector contains.

§Examples
use my_ecs::prelude::*;
use my_ecs::ds::AnyVec;

let mut v = AnyVec::new(tinfo!(i32));
unsafe {
    v.push(1_i32);
    v.push(2_i32);
}
let sum: i32 = v.par_iter_of::<i32>().sum();
assert_eq!(sum, 3);
Source

pub fn par_iter_mut_of<T: Send + Sync + 'static>(&mut self) -> ParIterMut<'_, T>

Returns mutable parallel iterator visiting all items.

Parallel iterator implements rayon’s parallel iterator traits, so that it can be split into multiple CPU cores then consumed at the same time.

§Panics

Panics if the given type is not the same as the vector contains.

§Examples
use my_ecs::prelude::*;
use my_ecs::ds::AnyVec;

let mut v = AnyVec::new(tinfo!(i32));
unsafe {
    v.push(1_i32);
    v.push(2_i32);
}
let sum: i32 = v.par_iter_mut_of::<i32>().map(|x| *x + 1).sum();
assert_eq!(sum, 5);
Source

pub fn reserve(&mut self, additional: usize)

Reserves additional capacity more than or equal to the given value.

If capacity of the vector is already sufficient, nothing takes place. Otherwise, allocates new memory or reallocates the old memory so that the capacity will be greater than or equal to self.len() + additional. This method deliberately allocates more memory than requested to avoid frequent reallocation.

§Panics

Panics if total memory in bytes after calling this method will exceed isize::MAX.

§Examples
use my_ecs::{tinfo, ds::AnyVec};

let mut v = AnyVec::new(tinfo!(i32));
v.reserve(10);
assert!(v.capacity() >= 10);
Source

pub fn reserve_exact(&mut self, additional: usize)

Reserves additional capacity as much as the given value.

If capacity of the vector is already sufficient, nothing takes place. Otherwise, allocates new memory or reallocates the old memory so that the capacity will be equal to self.len() + additional exactly.

Note, however, that allocator may give a memory block that is greater than requested for some reason. The exact size of memory block is invisible from clients, but you can look into it using something like libc::malloc_usable_size.

§Examples
use my_ecs::{tinfo, ds::AnyVec};

let mut v = AnyVec::new(tinfo!(i32));
v.reserve(10);
assert_eq!(v.capacity(), 10);
Source

pub fn shrink_to_fit(&mut self)

Shrinks capacity of the vector as much as possible.

§Examples
use my_ecs::{tinfo, ds::AnyVec};

let mut v = AnyVec::new(tinfo!(i32));
assert_eq!(v.capacity(), 0);

v.reserve(10);
assert!(v.capacity() >= 10);

unsafe { v.push(1_i32) };
v.shrink_to_fit();
assert!(v.capacity() >= 1);

v.pop_drop();
v.shrink_to_fit();
assert_eq!(v.capacity(), 0);
Source

pub unsafe fn set_len(&mut self, new_len: usize)

Sets length of the vector to the given value without any additional operations.

§Safety
  • new_len must be less than or equal to self.capacity().
  • If new_len is greater than the previous length, caller must initialize the extended range with proper values.
  • If new_len is less than the previous length, caller must drop abandoned values from the vector properly.
§Examples
use my_ecs::{tinfo, ds::AnyVec};

let mut v = AnyVec::new(tinfo!(i32));

unsafe {
    v.push(0_i32);
    v.set_len(0);
}
Source

pub unsafe fn set_raw_unchecked(&mut self, index: usize, src: NonNull<u8>)

Copies data as much as AnyVec::item_size from src address to the memory pointed by index.

Note that the old stored value is dropped before the copy, which means the given index must be in bounds.

§Safety
  • index must be in bounds.
  • src must point to a valid type that the vector contains.
  • Memory range pointed by index must not need to be dropped.
  • src must not be dropped after calling this method because it is moved into the vector.
§Examples
use my_ecs::{tinfo, ds::AnyVec};
use std::ptr::NonNull;

let mut v = AnyVec::new(tinfo!(i32));

unsafe {
    v.push(0_i32);
    let value = 1_i32;
    let ptr = (&value as *const i32 as *const u8).cast_mut();
    v.set_raw_unchecked(0, NonNull::new(ptr).unwrap());
    assert_eq!(v.pop(), Some(1_i32));
}
Source

pub unsafe fn push_raw(&mut self, src: NonNull<u8>)

Copies data as much as self.item_size() from src address to the end of the vector.

If the vector doesn’t have sufficient capacity for the appended value, then the vector increases its capacity first by calling AnyVec::reserve which allocates memory more than just one value, then does the copy.

§Safety
  • src must point to a valid type that the vector contains.
  • src must not be dropped after calling this method because it is moved into the vector.
§Examples
use my_ecs::{tinfo, ds::AnyVec};
use std::ptr::NonNull;

let mut v = AnyVec::new(tinfo!(i32));

let value = 0x01020304_i32;
unsafe {
    let ptr = (&value as *const i32 as *const u8).cast_mut();
    v.push_raw(NonNull::new(ptr).unwrap());
    assert_eq!(v.pop(), Some(value));
}
Source

pub unsafe fn push_with<F>(&mut self, write: F)
where F: FnOnce(*mut u8),

Writes a value to the end of the vector by calling the given function.

If the vector doesn’t have sufficient capacity for the appended value, then the vector increases its capacity first by calling AnyVec::reserve which allocates memory more than just one value, then does the write operation.

§Safety
  • write must write a valid type that the vector contains.
§Examples
use my_ecs::{tinfo, ds::AnyVec};
use std::ptr::{self, NonNull};

let mut v = AnyVec::new(tinfo!(i32));

let value = 0x01020304_i32;
unsafe {
    v.push_with(|dst| {
        ptr::write(dst as *mut i32, value);
    });
    assert_eq!(v.pop(), Some(value));
}
Source

pub unsafe fn push<T: 'static>(&mut self, value: T)

Appends the given value to the end of the vector.

§Safety
  • value must be the same type as the vector contains.
§Examples
use my_ecs::{tinfo, ds::AnyVec};

let mut v = AnyVec::new(tinfo!(i32));
unsafe {
    v.push(0_i32);
    assert_eq!(v.pop(), Some(0_i32));
}
Source

pub unsafe fn pop_raw(&mut self, buf: *mut u8) -> Option<()>

Removes the last item from the vector and writes it to the given buffer, then returns Some.

If removing is successful, caller becomes to own the item in the buffer, so that caller must call drop() on it correctly. Otherwise, returns None without change to the buffer.

§Safety

Undefined behavior if conditions below are not met.

  • buf must have enough size to be copied an item.
  • When Some is returned, buf must be correctly handled as an item. For example, if an item should be dropped, caller must call drop() on it.
  • When None is returned, buf must be correctly handled as it was.
§Examples
use my_ecs::{tinfo, ds::AnyVec};

let mut v = AnyVec::new(tinfo!(i32));
unsafe { v.push(42_i32) };
assert_eq!(v.len(), 1);

let mut buf = 0_i32;
let res = unsafe { v.pop_raw(&mut buf as *mut i32 as *mut u8) };
assert!(res.is_some());
assert!(v.is_empty());
assert_eq!(buf, 42);
Source

pub unsafe fn pop<T: 'static>(&mut self) -> Option<T>

Removes the last item from the vector.

§Safety
  • T must be the same type as the vector contains.
§Examples
use my_ecs::{tinfo, ds::AnyVec};

let mut v = AnyVec::new(tinfo!(i32));

unsafe {
    v.push(0_i32);
    let value = v.pop::<i32>().unwrap();
    assert_eq!(value, 0_i32);
}
Source

pub fn pop_drop(&mut self) -> Option<()>

Removes the last item from the vector then drops it immediately.

§Examples
use my_ecs::{tinfo, ds::AnyVec};

let mut v = AnyVec::new(tinfo!(i32));

unsafe {
    v.push(0_i32);
    assert_eq!(v.pop_drop(), Some(()));
}
Source

pub fn pop_forget(&mut self) -> Option<()>

Removes the last item from the vector without calling drop function on it.

§Safety

Rust safety doesn’t include calling drop function. See forget for more information. However, caller must guarantee that not calling drop function is fine for the item.

§Examples
use my_ecs::{tinfo, ds::AnyVec};

let mut v = AnyVec::new(tinfo!(i32));

unsafe {
    v.push(0_i32);
    assert_eq!(v.pop_forget(), Some(()));
}
Source

pub unsafe fn swap_remove_raw(&mut self, index: usize, buf: *mut u8)

Removes an item at the given index from the vector and writes it to the given buffer.

Therefore, the item is actually moved from the vector to the given buffer. So caller must take care of calling drop on it.

§Panics

Panics if the given index is out of bounds.

§Safety

Undefined behavior if conditions below are not met.

  • buf must have enough size to be copied an item.
  • When Some is returned, buf must be correctly handled as an item. For example, if an item should be dropped, caller must call drop() on it.
  • When None is returned, buf must be correctly handled as it was.
§Examples
use my_ecs::{tinfo, ds::AnyVec};

let mut v = AnyVec::new(tinfo!(i32));
unsafe {
    v.push(0_i32);
    v.push(1_i32);
    v.push(2_i32);
}
assert_eq!(v.len(), 3);

let mut buf = 3_i32;
unsafe { v.swap_remove_raw(0, &mut buf as *mut i32 as *mut u8) };
assert_eq!(buf, 0);

unsafe {
    assert_eq!(v.pop::<i32>(), Some(1));
    assert_eq!(v.pop::<i32>(), Some(2));
}
Source

pub unsafe fn swap_remove<T: 'static>(&mut self, index: usize) -> T

Removes an item at the given index from the vector and returns it.

Then the last item of the vector is moved to the vacant slot.

§Panics

Panics if the given index is out of bounds.

§Safety
  • T must be the same type as the vector contains.
§Examples
use my_ecs::{tinfo, ds::AnyVec};

let mut v = AnyVec::new(tinfo!(i32));

unsafe {
    v.push(0_i32);
    v.push(1_i32);
    v.push(2_i32);
    assert_eq!(v.swap_remove::<i32>(0), 0);
    assert_eq!(v.swap_remove::<i32>(0), 2);
    assert_eq!(v.swap_remove::<i32>(0), 1);
}
Source

pub fn swap_remove_drop(&mut self, index: usize)

Removes an item at the given index from the vector and drops it immediately.

Then the last item of the vector is moved to the vacant slot.

§Panics

Panics if the given index is out of bounds.

§Examples
use my_ecs::{tinfo, ds::AnyVec};

let mut v = AnyVec::new(tinfo!(i32));

unsafe {
    v.push(0_i32);
    v.swap_remove_drop(0);
    assert!(v.is_empty());
}
Source

pub fn swap_remove_forget(&mut self, index: usize)

Removes an item at the given index from the vector without calling drop function on it.

Then the last item of the vector is moved to the vacant slot.

§Panics

Panics if given index is out of bounds.

§Safety

Rust safety doesn’t include calling drop function. See forget for more information. However, caller must guarantee that not calling drop function is fine for the item.

§Examples
use my_ecs::{tinfo, ds::AnyVec};

let mut v = AnyVec::new(tinfo!(i32));

unsafe {
    v.push(0_i32);
    v.swap_remove_forget(0);
    assert!(v.is_empty());
}
Source

pub fn swap(&mut self, index0: usize, index1: usize)

Replaces an item with another item in the vector.

§Panics

Panics if any given indices is out of bounds.

§Examples
use my_ecs::{tinfo, ds::AnyVec};

let mut v = AnyVec::new(tinfo!(i32));

unsafe {
    v.push(0_i32);
    v.push(1_i32);
    v.swap(0, 1);
    assert_eq!(v.pop(), Some(0));
    assert_eq!(v.pop(), Some(1));
}
Source

pub fn get_raw(&self, index: usize) -> Option<NonNull<u8>>

Returns a pointer to an item at the given index.

§Examples
use my_ecs::{tinfo, ds::AnyVec};

let mut v = AnyVec::new(tinfo!(i32));

let value = 0x01020304_i32;
unsafe { v.push(value) };

let ptr = v.get_raw(0).unwrap().cast::<i32>().as_ptr().cast_const();
unsafe {
    assert_eq!(std::ptr::read(ptr), value);
}
Source

pub unsafe fn get_raw_unchecked(&self, index: usize) -> NonNull<u8>

Returns a pointer to an item at the given index.

§Safety
  • Index must be in bounds.
§Examples
use my_ecs::{tinfo, ds::AnyVec};

let mut v = AnyVec::new(tinfo!(i32));

let value = 0x01020304_i32;
unsafe {
    v.push(value);
    let ptr = v.get_raw_unchecked(0)
        .cast::<i32>()
        .as_ptr()
        .cast_const();
    assert_eq!(std::ptr::read(ptr), value);
}
Source

pub unsafe fn get<T: 'static>(&self, index: usize) -> Option<&T>

Returns shared reference to an item at the given index.

§Safety
  • T must be the same type as the vector contains.
§Examples
use my_ecs::{tinfo, ds::AnyVec};

let mut v = AnyVec::new(tinfo!(i32));

unsafe {
    v.push(0_i32);
    assert_eq!(v.get(0), Some(&0_i32));
}
Source

pub unsafe fn get_mut<T: 'static>(&mut self, index: usize) -> Option<&mut T>

Returns mutable reference to an item at the given index.

§Safety
  • T must be the same type as the vector contains.
§Examples
use my_ecs::{tinfo, ds::AnyVec};

let mut v = AnyVec::new(tinfo!(i32));

unsafe {
    v.push(0_i32);
    *v.get_mut(0).unwrap() = 1_i32;
    assert_eq!(v.get(0), Some(&1_i32));
}
Source

pub fn resize<T>(&mut self, new_len: usize, value: T)
where T: Clone + 'static,

Resizes the vector to the given length.

If the new length is greater than previous length of the vector, then the vector is extended with the given value. Otherwise, the vector is shrunk.

§Panics

Panics if T is not the same type as the vector contains.

§Examples
use my_ecs::{tinfo, ds::AnyVec};

let mut v = AnyVec::new(tinfo!(i32));

unsafe {
    v.resize(2, 0_i32);
    assert_eq!(v.pop(), Some(0_i32));
    assert_eq!(v.pop(), Some(0_i32));
    assert!(v.is_empty());
}
Source

pub unsafe fn resize_raw(&mut self, new_len: usize, val_ptr: NonNull<u8>)

Resizes the vector to the given length.

If the new length is greater than previous length of the vector, then the vector is extended with clones of a value pointed by the given pointer. Otherwise, the vector is shrunk.

§Panics

Panics if vector item is not Clone.

§Safety
  • val_ptr must point to a valid type that the vector contains.
§Examples
use my_ecs::{tinfo, ds::AnyVec};
use std::ptr::NonNull;

let mut v = AnyVec::new(tinfo!(i32));

let value = 0x01020304_i32;
unsafe {
    let ptr = (&value as *const i32 as *const u8).cast_mut();
    v.resize_raw(2, NonNull::new(ptr).unwrap());
    assert_eq!(v.pop(), Some(value));
    assert_eq!(v.pop(), Some(value));
    assert!(v.is_empty());
}
Source

pub fn resize_with<T, F>(&mut self, new_len: usize, f: F)
where T: 'static, F: FnMut() -> T,

Resizes the vector to the given length.

If the new length is greater than previous length of the vector, then the vector is extended with values the given function generates. In this case, generated values are appended in order. Otherwise, the vector is shrunk.

§Panics

Panics if T is not the same type as the vector contains.

§Examples
use my_ecs::{tinfo, ds::AnyVec};

let mut v = AnyVec::new(tinfo!(i32));

unsafe {
    v.resize_with(2, || 0_i32);
    assert_eq!(v.pop(), Some(0_i32));
    assert_eq!(v.pop(), Some(0_i32));
    assert!(v.is_empty());
}
Source

pub fn truncate(&mut self, len: usize)

Shrinks the vector to the given length, and drops abandoned items.

If the given length is greater than or equal to the current length of the vector, nothing takes place.

§Examples
use my_ecs::{tinfo, ds::AnyVec};

let mut v = AnyVec::new(tinfo!(i32));

unsafe { v.resize(10, 0_i32) };
v.truncate(5);
assert_eq!(v.len(), 5);
Source

pub fn as_vec_mut<T: 'static>(&mut self) -> TypedAnyVec<'_, T>

Creates TypedAnyVec which looks like Vec<T>.

You can call tons of useful methods on Vec by converting the vector.

§Panics

Panics if T it not the same type as the vector contains.

§Examples
use my_ecs::{tinfo, ds::AnyVec};

let mut v = AnyVec::new(tinfo!(i32));
{
    let mut tv = v.as_vec_mut::<i32>();
    tv.push(0);
    tv.push(1);
}
unsafe {
    assert_eq!(v.pop(), Some(1_i32));
    assert_eq!(v.pop(), Some(0_i32));
}
Source

pub fn as_slice<T: 'static>(&self) -> &[T]

Creates a slice from the vector.

§Panics

Panics if T it not the same type as the vector contains.

§Examples
use my_ecs::{tinfo, ds::AnyVec};

let mut v = AnyVec::new(tinfo!(i32));
unsafe {
    v.push(0_i32);
    v.push(1_i32);
}
assert_eq!(v.as_slice::<i32>(), &[0, 1]);
Source

pub fn as_mut_slice<T: 'static>(&mut self) -> &mut [T]

Creates a mutable slice from the vector.

§Panics

Panics if T it not the same type as the vector contains.

§Examples
use my_ecs::{tinfo, ds::AnyVec};

let mut v = AnyVec::new(tinfo!(i32));
unsafe { v.push(0_i32) };
let slice = v.as_mut_slice::<i32>();
assert_eq!(slice, &mut [0]);

Trait Implementations§

Source§

impl AsRawIter for AnyVec

Source§

fn iter(&self) -> RawIter

Returns a new RawIter. Read more
Source§

fn par_iter(&self) -> ParRawIter

Returns a new ParRawIter. Read more
Source§

unsafe fn iter_of<T>(&self) -> Iter<'_, T>

Returns a new iterator. Read more
Source§

unsafe fn iter_mut_of<T>(&mut self) -> IterMut<'_, T>

Returns a new mutable iterator. Read more
Source§

unsafe fn par_iter_of<T>(&self) -> ParIter<'_, T>

Returns a new parallel iterator. Read more
Source§

unsafe fn par_iter_mut_of<T>(&mut self) -> ParIterMut<'_, T>

Returns a new parallel mutable iterator. Read more
Source§

impl Clone for AnyVec

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AnyVec

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for AnyVec

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl IntoIterator for &AnyVec

Source§

type Item = SendSyncPtr<u8>

The type of the elements being iterated over.
Source§

type IntoIter = RawIter

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'data> IntoParallelRefIterator<'data> for AnyVec

Source§

type Iter = ParRawIter

The type of the parallel iterator that will be returned.
Source§

type Item = SendSyncPtr<u8>

The type of item that the parallel iterator will produce. This will typically be an &'data T reference type.
Source§

fn par_iter(&'data self) -> Self::Iter

Converts self into a parallel iterator. Read more
Source§

impl Resource for AnyVec

Source§

impl Send for AnyVec

Source§

impl Sync for AnyVec

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.