[−][src]Struct region_buffer::RegionBuffer
A contiguous growable array type, allow you to obtain multiple mutable regions from it, as long these regions don't overlap.
Methods
impl<T> RegionBuffer<T>[src]
impl<T> RegionBuffer<T>pub fn new() -> Self[src]
pub fn new() -> SelfConstructs a new, empty RegionBuffer<T>. The buffer will not allocate
until elements are pushed onto it.
pub fn push(&mut self, element: T)[src]
pub fn push(&mut self, element: T)Appends an element to the back of a collection.
Panics
Panics if the number of elements in the buffer overflows a usize.
pub fn len(&self) -> usize[src]
pub fn len(&self) -> usizeReturns the number of elements in the buffer, also referred to as its 'length'.
pub fn is_empty(&self) -> bool[src]
pub fn is_empty(&self) -> boolReturns true if the region buffer contains no elements.
pub fn truncate(&mut self, len: usize)[src]
pub fn truncate(&mut self, len: usize)Shortens the buffer, keeping the first len elements and dropping the
rest. If len is greater than the buffer's current length, this has no
effect.
Note that this method has no effect on the allocated capacity of the buffer.
Panics
If len is less than an already borrowed region.
pub fn region(&self, start: usize, end: usize) -> Slice<T>[src]
pub fn region(&self, start: usize, end: usize) -> Slice<T>Provides a mutable reference to a region in the buffer, provided that region hasn't already been borrowed.
Panics
If the region has already been borrowed.
pub fn get(&self, index: usize) -> Element<T>[src]
pub fn get(&self, index: usize) -> Element<T>Returns a single element from the buffer. The borrowing rules also apply to this single element, so you can't get a single element from an already borrowed region and vice versa.
pub fn get_mut<'a>(&self, index: usize) -> ElementMut<'a, T>[src]
pub fn get_mut<'a>(&self, index: usize) -> ElementMut<'a, T>Returns a single mutable element from the buffer. The borrowing rules also apply to this single element, so you can't get a single element from an already borrowed region and vice versa.
impl<T: Clone> RegionBuffer<T>[src]
impl<T: Clone> RegionBuffer<T>pub fn from_elements(element: T, len: usize) -> Self[src]
pub fn from_elements(element: T, len: usize) -> SelfInitialise a buffer of len size, with all elements initialised to
element.
pub fn expand(&mut self, to: usize, element: T)[src]
pub fn expand(&mut self, to: usize, element: T)Expands the region by to size, with all new elements initialised to
element.
Trait Implementations
impl<T: Default> Default for RegionBuffer<T>[src]
impl<T: Default> Default for RegionBuffer<T>fn default() -> RegionBuffer<T>[src]
fn default() -> RegionBuffer<T>impl<T: Debug> Debug for RegionBuffer<T>[src]
impl<T: Debug> Debug for RegionBuffer<T>Auto Trait Implementations
impl<T> Send for RegionBuffer<T> where
T: Send,
impl<T> Send for RegionBuffer<T> where
T: Send, impl<T> Sync for RegionBuffer<T> where
T: Sync,
impl<T> Sync for RegionBuffer<T> where
T: Sync, Blanket Implementations
impl<T> From for T[src]
impl<T> From for Timpl<T, U> Into for T where
U: From<T>, [src]
impl<T, U> Into for T where
U: From<T>, impl<T, U> TryFrom for T where
T: From<U>, [src]
impl<T, U> TryFrom for T where
T: From<U>, type Error = !
try_from)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>impl<T> Borrow for T where
T: ?Sized, [src]
impl<T> Borrow for T where
T: ?Sized, impl<T, U> TryInto for T where
U: TryFrom<T>, [src]
impl<T, U> TryInto for T where
U: TryFrom<T>, type Error = <U as TryFrom<T>>::Error
try_from)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>impl<T> BorrowMut for T where
T: ?Sized, [src]
impl<T> BorrowMut for T where
T: ?Sized, fn borrow_mut(&mut self) -> &mut T[src]
fn borrow_mut(&mut self) -> &mut Timpl<T> Any for T where
T: 'static + ?Sized, [src]
impl<T> Any for T where
T: 'static + ?Sized, fn get_type_id(&self) -> TypeId[src]
fn get_type_id(&self) -> TypeId