Struct rsynth::vecstorage::VecStorage [−]
Re-usable memory for creating a vector of references.
See the module-level documentation for more information.
Implementations
impl<T> VecStorage<T>
pub fn with_capacity(capacity: usize) -> VecStorage<T>
Create a new VecStorage<T>
with the provided capacity.
Example
use vecstorage::VecStorage; let storage = VecStorage::<u32>::with_capacity(5); assert_eq!(storage.capacity(), 5);
pub fn capacity(&self) -> usize
Get the capacity of the VecStorage
.
Example
use vecstorage::VecStorage; let storage = VecStorage::<u32>::with_capacity(5); assert_eq!(storage.capacity(), 5);
pub fn vec_guard<TGuard>(&'s mut self) -> VecGuard<'s, T, TGuard>
Creates a new [VecGuard
] using the memory allocated by self
.
This VecGuard` will automatically clear the vector when it goes out of scope.
Panics
Panics if TGuard
doesn’t have the same size and alignment as T
.
Panics if mem::forget()
was called on a [VecGuard
]
that was created previously on the same VecStorage
.
Example
use vecstorage::VecStorage; let mut storage = VecStorage::<u32>::with_capacity(2); { let mut guard = storage.vec_guard(); assert_eq!(guard.capacity(), 2); assert_eq!(guard.len(), 0); guard.push(3); guard.push(2); } { let mut guard = storage.vec_guard::<u32>(); assert_eq!(guard.capacity(), 2); // The memory of the `storage` is reused assert_eq!(guard.len(), 0); // But its contents has been "cleared". }
Trait Implementations
impl<T> Debug for VecStorage<T> where
T: Debug,
T: Debug,
impl<T> Drop for VecStorage<T>
pub fn drop(&mut self)
impl<T> Send for VecStorage<T> where
T: Send,
T: Send,
impl<T> Sync for VecStorage<T> where
T: Sync,
T: Sync,
Auto Trait Implementations
impl<T> RefUnwindSafe for VecStorage<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Unpin for VecStorage<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for VecStorage<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<S, T> Duplex<S> for T where
T: FromSample<S> + ToSample<S>,
T: FromSample<S> + ToSample<S>,
impl<T> From<T> for T
[src]
impl<S> FromSample<S> for S
pub fn from_sample_(s: S) -> S
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> ToSample<U> for T where
U: FromSample<T>,
U: FromSample<T>,
pub fn to_sample_(self) -> U
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,