[−][src]Struct safe_index::examples::clients::idx::Files
Map from files to something.
Implementations
impl<T> Files<T>
[src]
pub fn of(vec: Vec<T>) -> Self
[src]
Creates an empty map from an existing one.
pub fn new() -> Self
[src]
Creates an empty map.
pub fn with_capacity(capacity: usize) -> Self
[src]
Creates an empty map with some capacity.
pub fn reserve(&mut self, capa: usize)
[src]
Reserves some space for the map.
pub fn get(&self, uid: File) -> Option<&T>
[src]
Retrieves an entry in the map.
pub fn get_mut(&mut self, uid: File) -> Option<&mut T>
[src]
Retrieves an entry in the map.
pub fn last(&self) -> Option<&T>
[src]
Retrieves the last entry in the map.
pub fn last_mut(&self) -> Option<&T>
[src]
Retrieves the last entry in the map.
pub fn len(&self) -> usize
[src]
Number of elements in the map.
pub fn capacity(&self) -> usize
[src]
Capacity of the map.
pub fn next_index(&self) -> File
[src]
The next free index (wrapped self.len()
).
pub fn last_index(&self) -> Option<File>
[src]
The last index in the map.
pub fn push(&mut self, elem: T) -> File
[src]
Pushes an element.
pub fn pop(&mut self) -> Option<T>
[src]
Pops an element.
This function is unsafe for the logics of safe indices. This function voids indices previously created (indices for the last element on entry) and should be used with great care.
pub fn clear(&mut self)
[src]
Clears a map.
pub fn iter(&self) -> Iter<'_, T>
[src]
Iterates over the elements.
pub fn index_iter<'a>(&'a self) -> FileIter<&'a Files<T>>ⓘ where
T: 'a,
[src]
T: 'a,
Iterates over the elements with the index.
pub fn index_iter_mut<'a>(&'a mut self) -> FileIter<IterMut<'a, T>>ⓘ where
T: 'a,
[src]
T: 'a,
Iterates over the elements with the index, mutable version.
pub fn into_index_iter(self) -> FileIter<Files<T>>ⓘ
[src]
Iterates over the elements with the index.
pub fn iter_mut(&mut self) -> IterMut<'_, T>
[src]
Iterates over the elements (mutable version).
pub fn shrink_to_fit(&mut self)
[src]
Shrinks the capacity as much as possible.
pub fn swap(&mut self, a: File, b: File)
[src]
Swap from Vec
.
pub fn swap_remove(&mut self, idx: File) -> T
[src]
Swap remove from Vec
.
This function is unsafe for the logics of safe indices. This function voids indices previously created (indices for the last element on entry) and should be used with great care.
pub fn split(
&self,
idx: File
) -> (impl Iterator<Item = &T>, &T, impl Iterator<Item = &T>)
[src]
&self,
idx: File
) -> (impl Iterator<Item = &T>, &T, impl Iterator<Item = &T>)
Splits the map into the elements before and after some index.
More precisely, returns a tuple of
- an iterator over the elements before
idx
, - the element at position
idx
, and - an iterator over the elements after
idx
.
impl<T: Clone> Files<T>
[src]
Methods from Deref<Target = Vec<T>>
pub fn capacity(&self) -> usize
1.0.0[src]
Returns the number of elements the vector can hold without reallocating.
Examples
let vec: Vec<i32> = Vec::with_capacity(10); assert_eq!(vec.capacity(), 10);
pub fn as_slice(&self) -> &[T]
1.7.0[src]
Extracts a slice containing the entire vector.
Equivalent to &s[..]
.
Examples
use std::io::{self, Write}; let buffer = vec![1, 2, 3, 5, 8]; io::sink().write(buffer.as_slice()).unwrap();
pub fn as_ptr(&self) -> *const T
1.37.0[src]
Returns a raw pointer to the vector's buffer.
The caller must ensure that the vector outlives the pointer this function returns, or else it will end up pointing to garbage. Modifying the vector may cause its buffer to be reallocated, which would also make any pointers to it invalid.
The caller must also ensure that the memory the pointer (non-transitively) points to
is never written to (except inside an UnsafeCell
) using this pointer or any pointer
derived from it. If you need to mutate the contents of the slice, use as_mut_ptr
.
Examples
let x = vec![1, 2, 4]; let x_ptr = x.as_ptr(); unsafe { for i in 0..x.len() { assert_eq!(*x_ptr.add(i), 1 << i); } }
pub fn len(&self) -> usize
1.0.0[src]
Returns the number of elements in the vector, also referred to as its 'length'.
Examples
let a = vec![1, 2, 3]; assert_eq!(a.len(), 3);
pub fn is_empty(&self) -> bool
1.0.0[src]
Returns true
if the vector contains no elements.
Examples
let mut v = Vec::new(); assert!(v.is_empty()); v.push(1); assert!(!v.is_empty());
Trait Implementations
impl<T: Clone> Clone for Files<T>
[src]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T: Debug> Debug for Files<T>
[src]
impl<T> Default for Files<T>
[src]
impl<T> Deref for Files<T>
[src]
impl<T: Eq> Eq for Files<T>
[src]
impl<T> From<Vec<T>> for Files<T>
[src]
impl<T> FromIterator<T> for Files<T>
[src]
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
[src]
impl<T> Index<File> for Files<T>
[src]
impl<T> Index<Range<File>> for Files<T>
[src]
type Output = [T]
The returned type after indexing.
fn index(&self, std::ops::Range { start: start, end: end }: Range<File>) -> &[T]
[src]
impl<T> Index<Range<usize>> for Files<T>
[src]
type Output = [T]
The returned type after indexing.
fn index(&self, index: Range<usize>) -> &[T]
[src]
impl<T> Index<RangeFrom<File>> for Files<T>
[src]
type Output = [T]
The returned type after indexing.
fn index(&self, std::ops::RangeFrom { start: start }: RangeFrom<File>) -> &[T]
[src]
impl<T> Index<RangeFrom<usize>> for Files<T>
[src]
type Output = [T]
The returned type after indexing.
fn index(&self, index: RangeFrom<usize>) -> &[T]
[src]
impl<T> Index<RangeFull> for Files<T>
[src]
impl<T> Index<RangeInclusive<File>> for Files<T>
[src]
type Output = [T]
The returned type after indexing.
fn index(&self, range: RangeInclusive<File>) -> &[T]
[src]
impl<T> Index<RangeInclusive<usize>> for Files<T>
[src]
type Output = [T]
The returned type after indexing.
fn index(&self, index: RangeInclusive<usize>) -> &[T]
[src]
impl<T> Index<RangeTo<File>> for Files<T>
[src]
type Output = [T]
The returned type after indexing.
fn index(&self, std::ops::RangeTo { end: end }: RangeTo<File>) -> &[T]
[src]
impl<T> Index<RangeTo<usize>> for Files<T>
[src]
type Output = [T]
The returned type after indexing.
fn index(&self, index: RangeTo<usize>) -> &[T]
[src]
impl<T> Index<RangeToInclusive<File>> for Files<T>
[src]
type Output = [T]
The returned type after indexing.
fn index(
&self,
std::ops::RangeToInclusive { end: end }: RangeToInclusive<File>
) -> &[T]
[src]
&self,
std::ops::RangeToInclusive { end: end }: RangeToInclusive<File>
) -> &[T]
impl<T> IndexMut<File> for Files<T>
[src]
impl<T> IntoIterator for Files<T>
[src]
type Item = T
The type of the elements being iterated over.
type IntoIter = IntoIter<T>
Which kind of iterator are we turning this into?
fn into_iter(self) -> IntoIter<T>
[src]
impl<'a, T> IntoIterator for &'a Files<T>
[src]
type Item = &'a T
The type of the elements being iterated over.
type IntoIter = Iter<'a, T>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Iter<'a, T>
[src]
impl<'a, T> IntoIterator for &'a mut Files<T>
[src]
type Item = &'a mut T
The type of the elements being iterated over.
type IntoIter = IterMut<'a, T>
Which kind of iterator are we turning this into?
fn into_iter(self) -> IterMut<'a, T>
[src]
impl<T: Ord> Ord for Files<T>
[src]
fn cmp(&self, other: &Files<T>) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<T: PartialEq> PartialEq<Files<T>> for Files<T>
[src]
impl<T: PartialOrd> PartialOrd<Files<T>> for Files<T>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for Files<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Files<T> where
T: Send,
T: Send,
impl<T> Sync for Files<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Files<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Files<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<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<I> IntoIterator for I where
I: Iterator,
[src]
I: Iterator,
type Item = <I as Iterator>::Item
The type of the elements being iterated over.
type IntoIter = I
Which kind of iterator are we turning this into?
pub fn into_iter(self) -> I
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
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>,